47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
export const shorthands = undefined;
|
|
|
|
/**
|
|
* @param pgm {import('node-pg-migrate').MigrationBuilder}
|
|
* @param run {() => void | undefined}
|
|
* @returns {Promise<void> | void}
|
|
*/
|
|
export function up(pgm) {
|
|
pgm.createTable('users', {
|
|
id: 'id',
|
|
username: {type:"varchar(32)", notNull: true},
|
|
password: {type:"char(60)", notNull: true}
|
|
})
|
|
|
|
pgm.addColumn('captchas', {
|
|
submitter: {type: 'integer', references: 'users(id)'}
|
|
});
|
|
|
|
pgm.dropType('protocol_type', {cascade: true});
|
|
pgm.dropTable('proxies', {cascade: true});
|
|
pgm.dropColumn('captchas', 'proxy_id', {cascade: true});
|
|
}
|
|
|
|
/**
|
|
* @param pgm {import('node-pg-migrate').MigrationBuilder}
|
|
* @param run {() => void | undefined}
|
|
* @returns {Promise<void> | void}
|
|
*/
|
|
export function down(pgm) {
|
|
pgm.dropTable('users');
|
|
pgm.dropColumn('captchas', 'submitter');
|
|
|
|
pgm.createType('protocol_type', ['http', 'https']);
|
|
|
|
pgm.createTable('proxies', {
|
|
id: 'id',
|
|
proto: {type: 'protocol_type', notNull: true},
|
|
claimed: {type: 'boolean', default: false},
|
|
host: {type: 'inet', notNull: true},
|
|
port: {type: 'smallint', notNull: true},
|
|
username: {type: 'varchar(16)'},
|
|
password: {type: 'varchar(32)'}
|
|
});
|
|
|
|
pgm.addColumn('captchas', {proxy_id: {type: 'integer', references: 'proxies(id)'}});
|
|
}
|