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,26 @@
exports.up = (pgm) => {
pgm.createTable('trips', {
id: { type: 'uuid', primaryKey: true, default: pgm.func('gen_random_uuid()') },
name: { type: 'text', notNull: true },
description: { type: 'text' },
owner_id: { type: 'uuid', notNull: true, references: 'users(id)' },
start_date: { type: 'date' },
end_date: { type: 'date' },
status: { type: 'text', notNull: true, default: 'DRAFT' },
planning_stage: { type: 'text' },
currency: { type: 'text', notNull: true, default: 'EUR' },
version: { type: 'integer', notNull: true, default: 1 },
created_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
updated_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
});
pgm.addConstraint(
'trips',
'trips_status_check',
"CHECK (status IN ('DRAFT','PLANNING','BOOKING','UPCOMING','ACTIVE','COMPLETED','ARCHIVED'))",
);
pgm.createIndex('trips', 'owner_id');
};
exports.down = (pgm) => {
pgm.dropTable('trips');
};