Initial commit
This commit is contained in:
29
migrations/20251123_create_charger_schedules.js
Normal file
29
migrations/20251123_create_charger_schedules.js
Normal file
@@ -0,0 +1,29 @@
|
||||
exports.up = async function (knex) {
|
||||
const exists = await knex.schema.hasTable('charger_schedules');
|
||||
if (exists) return;
|
||||
|
||||
return knex.schema.createTable('charger_schedules', (t) => {
|
||||
t.uuid('id')
|
||||
.primary()
|
||||
.defaultTo(knex.raw('gen_random_uuid()'));
|
||||
|
||||
t.uuid('charger_id')
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('chargers')
|
||||
.onDelete('CASCADE');
|
||||
|
||||
t.string('start', 5).notNullable();
|
||||
t.string('end', 5).notNullable();
|
||||
|
||||
t.enu('repeat', ['everyday', 'weekdays', 'weekends'])
|
||||
.notNullable()
|
||||
.defaultTo('everyday');
|
||||
|
||||
t.timestamp('created_at').defaultTo(knex.fn.now());
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.dropTableIfExists('charger_schedules');
|
||||
};
|
||||
Reference in New Issue
Block a user