27 lines
1015 B
JavaScript
27 lines
1015 B
JavaScript
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');
|
|
};
|