Complete migrations
This commit is contained in:
parent
c9ad8b30c7
commit
8af2a70f00
108
migrations/0_initial-migration.js
Normal file
108
migrations/0_initial-migration.js
Normal file
@ -0,0 +1,108 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
exports.shorthands = {
|
||||
id: { type: 'serial', primaryKey: true },
|
||||
varchar: { type: 'varchar(128)' },
|
||||
varchar_req: { type: 'varchar(128)', notNull: true }
|
||||
};
|
||||
|
||||
exports.up = (pgm) => {
|
||||
pgm.createTable('account', {
|
||||
id: 'id',
|
||||
username: 'varchar_req',
|
||||
email: 'varchar_req',
|
||||
password: 'varchar_req',
|
||||
timezone: 'varchar',
|
||||
earliest_time: 'time',
|
||||
latest_time: 'time',
|
||||
createdAt: {
|
||||
type: 'timestamp',
|
||||
notNull: true,
|
||||
default: pgm.func('current_timestamp'),
|
||||
},
|
||||
});
|
||||
|
||||
pgm.createTable('meeting', {
|
||||
id: { type: 'uuid', primaryKey: true },
|
||||
title: 'varchar_req',
|
||||
description: 'varchar',
|
||||
start_time: 'time',
|
||||
timezone: 'varchar',
|
||||
duration: 'int',
|
||||
status: 'boolean',
|
||||
password: 'varchar',
|
||||
createdAt: {
|
||||
type: 'timestamp',
|
||||
notNull: true,
|
||||
default: pgm.func('current_timestamp'),
|
||||
},
|
||||
});
|
||||
|
||||
pgm.createTable('possible_date', {
|
||||
id: 'id',
|
||||
meeting_id: {
|
||||
type: 'uuid',
|
||||
references: 'meeting(id)',
|
||||
notNull: true,
|
||||
onDelete: 'cascade',
|
||||
},
|
||||
possible_date: { type: 'date', notNull: true },
|
||||
});
|
||||
|
||||
pgm.createTable('participant', {
|
||||
id: 'id',
|
||||
account_id: {
|
||||
type: 'int',
|
||||
references: 'account(id)',
|
||||
notNull: true,
|
||||
onDelete: 'cascade',
|
||||
},
|
||||
meeting_id: {
|
||||
type: 'uuid',
|
||||
references: 'meeting(id)',
|
||||
notNull: true,
|
||||
onDelete: 'cascade',
|
||||
},
|
||||
earliest_time: 'time',
|
||||
latest_time: 'time',
|
||||
quorum: 'boolean',
|
||||
mandatory: 'boolean',
|
||||
host: 'boolean',
|
||||
answered: 'boolean',
|
||||
timezone: 'varchar',
|
||||
createdAt: {
|
||||
type: 'timestamp',
|
||||
notNull: true,
|
||||
default: pgm.func('current_timestamp'),
|
||||
},
|
||||
});
|
||||
|
||||
pgm.createTable('availibility', {
|
||||
id: 'id',
|
||||
participant_id: {
|
||||
type: 'id',
|
||||
references: 'participant(id)',
|
||||
notNull: true,
|
||||
onDelete: 'cascade',
|
||||
},
|
||||
possible_date_id: {
|
||||
type: 'id',
|
||||
references: 'possible_date(id)',
|
||||
notNull: true,
|
||||
onDelete: 'cascade',
|
||||
},
|
||||
preference: { type: 'boolean', notNull: true },
|
||||
start_time: { type: 'timestamp', notNull: true },
|
||||
end_time: { type: 'timestamp', notNull: true },
|
||||
timezone: 'varchar_req',
|
||||
createdAt: {
|
||||
type: 'timestamp',
|
||||
notNull: true,
|
||||
default: pgm.func('current_timestamp'),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
// exports.down = (pgm) => {
|
||||
// pgm.dropTable('accounts', { ifExists: true });
|
||||
// };
|
@ -1,28 +0,0 @@
|
||||
/* 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 });
|
||||
};
|
Loading…
Reference in New Issue
Block a user