backend/migrations/1_initial-migration.js
2020-04-30 20:39:51 +02:00

29 lines
686 B
JavaScript

/* eslint-disable camelcase */
exports.shorthands = {
uuid: { type: 'uuid', primaryKey: true },
id: { type: 'serial', primaryKey: true },
timezone: { type: 'varchar(128)' },
};
exports.up = (pgm) => {
pgm.createTable('accounts', {
id: 'id',
username: { type: 'varchar(128)', notNull: true },
email: { type: 'varchar(128)', notNull: true },
password: { type: 'varchar(128)', notNull: true },
timezone: 'timezone',
earliest_time: { type: 'time' },
latest_time: { type: 'time' },
createdAt: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp'),
},
});
};
exports.down = (pgm) => {
pgm.dropTable('accounts', { ifExists: true });
};