9854ca2f59
Mirror to GitHub / mirror (push) Successful in 27s
Test and Lint / backend-test (push) Successful in 1m21s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m4s
Version and Release / version-bump (push) Failing after 31s
Version and Release / trigger-drone (push) Has been skipped
- Created core/ directory for essential migrations that always run - Created legacy/ directory for migrations only needed when upgrading - New deployments will only run core migrations for a clean database - Existing deployments will run all migrations in proper sequence - Fixed duplicate migration numbers (014 and 027) - Updated migration runners to handle new directory structure - Added README explaining the migration organization This change optimizes deployment for new users who will get a clean schema without running unnecessary upgrade migrations.
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
exports.up = function(knex) {
|
|
return knex.schema
|
|
// Table for individual token revocations
|
|
.createTable('revoked_tokens', table => {
|
|
table.increments('id').primary();
|
|
table.string('token_id').notNullable().unique(); // JWT ID or generated ID
|
|
table.integer('user_id').nullable(); // User who owned the token
|
|
table.string('token_type', 20); // admin, gallery, etc.
|
|
table.timestamp('revoked_at').defaultTo(knex.fn.now());
|
|
table.timestamp('expires_at').notNullable(); // When token would have expired
|
|
table.string('reason', 100); // password_change, logout, compromised, etc.
|
|
table.text('metadata'); // Additional JSON data
|
|
|
|
// Indexes for performance
|
|
table.index('token_id');
|
|
table.index('user_id');
|
|
table.index('expires_at'); // For cleanup
|
|
})
|
|
// Table for user-level revocations (revoke all tokens before a certain time)
|
|
.createTable('user_token_revocations', table => {
|
|
table.integer('user_id').primary();
|
|
table.timestamp('revoked_at').notNullable();
|
|
table.string('reason', 100);
|
|
|
|
// Index for quick lookups
|
|
table.index('revoked_at');
|
|
});
|
|
};
|
|
|
|
exports.down = function(knex) {
|
|
return knex.schema
|
|
.dropTableIfExists('user_token_revocations')
|
|
.dropTableIfExists('revoked_tokens');
|
|
}; |