Skip to content

Conversation

@pyramation
Copy link
Contributor

refactor: migrate from tokens_module to sessions_module

Summary

BREAKING CHANGE: This PR completely removes tokens_module and replaces it with sessions_module for session-centric authentication.

Key changes:

  • Removed tokens_module (deploy/revert/verify SQL files)
  • Added sessions_module with columns for sessions_table, session_credentials_table, and auth_settings_table
  • Updated crypto_auth_module to use sessions_table_id and session_credentials_table_id instead of tokens_table_id
  • Updated user_auth_module similarly - replaced tokens references with sessions references
  • Updated pgpm.plan to reflect new module dependencies
  • Updated tests to verify sessions_module structure instead of tokens_module

Review & Testing Checklist for Human

This is a breaking change affecting core authentication infrastructure. Please verify:

  • Verify no downstream dependencies: Confirm that no other code in your stack depends on tokens_module or tokens_table_id columns
  • Test pgpm migration: Run pgpm deploy and verify the new sessions_module table is created correctly with all FK constraints
  • Verify FK relationships: The new sessions_table_fkey and session_credentials_table_fkey constraints should reference metaschema_public.table correctly
  • Run the test suite: Execute pnpm test in packages/metaschema-modules to verify all tests pass with the new structure
  • Check for data migration needs: If any existing databases have tokens_module data, plan for migration before deploying

Recommended Test Plan

  1. Run pnpm test in the metaschema-modules package
  2. Deploy to a test database and verify sessions_module table exists with correct columns
  3. Verify crypto_auth_module and user_auth_module tables have the new sessions_table_id and session_credentials_table_id columns

Notes

This change is part of a larger migration from token-based auth to session-centric auth in the constructive-db ecosystem. The companion PR in constructive-db (PR #458) contains the corresponding changes to the auth functions.

Link to Devin run: https://app.devin.ai/sessions/d30b2724020f43f6b94865bbd5cf71c6
Requested by: @pyramation

BREAKING CHANGE: tokens_module has been removed entirely.

- Remove tokens_module (deploy, revert, verify)
- Add sessions_module for session-centric authentication
- Update crypto_auth_module to use sessions_table_id and session_credentials_table_id
- Update user_auth_module to use sessions_table_id and session_credentials_table_id
- Update pgpm.plan to reflect new module dependencies
- Update tests to remove tokens_module references
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 7439d80 into main Jan 28, 2026
22 checks passed
@pyramation pyramation deleted the devin/1769595123-sessions-migration branch January 28, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants