feat: add versioned migrations and kysely query layer

This commit is contained in:
Bastian Wagner
2026-08-17 14:33:28 +02:00
parent acfbb3ab22
commit ec95a8e527
17 changed files with 513 additions and 50 deletions

View File

@@ -0,0 +1,20 @@
exports.up = (pgm) => {
pgm.createTable('trip_invitations', {
id: { type: 'uuid', primaryKey: true, default: pgm.func('gen_random_uuid()') },
trip_id: { type: 'uuid', notNull: true, references: 'trips(id)', onDelete: 'CASCADE' },
email: { type: 'text', notNull: true },
invited_by_user_id: { type: 'uuid', notNull: true, references: 'users(id)' },
token_hash: { type: 'text', notNull: true },
expires_at: { type: 'timestamptz', notNull: true },
accepted_at: { type: 'timestamptz' },
created_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
updated_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
});
pgm.addConstraint('trip_invitations', 'trip_invitations_token_hash_key', 'UNIQUE(token_hash)');
pgm.createIndex('trip_invitations', 'trip_id');
pgm.sql('CREATE INDEX trip_invitations_lower_email_idx ON trip_invitations (lower(email))');
};
exports.down = (pgm) => {
pgm.dropTable('trip_invitations');
};