feat: add versioned migrations and kysely query layer
This commit is contained in:
16
backend/migrations/1700000001000_create-users.cjs
Normal file
16
backend/migrations/1700000001000_create-users.cjs
Normal file
@@ -0,0 +1,16 @@
|
||||
exports.up = (pgm) => {
|
||||
pgm.createExtension('pgcrypto', { ifNotExists: true });
|
||||
pgm.createTable('users', {
|
||||
id: { type: 'uuid', primaryKey: true, default: pgm.func('gen_random_uuid()') },
|
||||
external_subject_id: { type: 'text', notNull: true },
|
||||
display_name: { type: 'text', notNull: true },
|
||||
email: { type: 'text', notNull: true },
|
||||
created_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
|
||||
updated_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
|
||||
});
|
||||
pgm.addConstraint('users', 'users_external_subject_id_key', 'UNIQUE(external_subject_id)');
|
||||
};
|
||||
|
||||
exports.down = (pgm) => {
|
||||
pgm.dropTable('users');
|
||||
};
|
||||
Reference in New Issue
Block a user