You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
825 B
JavaScript
30 lines
825 B
JavaScript
'use strict';
|
|
|
|
module.exports.up = function(knex, Promise) {
|
|
return Promise.try(() => {
|
|
return knex.schema.createTable("users", (table) => {
|
|
table.bigIncrements("id").primary();
|
|
table.text("username").notNull();
|
|
table.text("password_hash");
|
|
table.enum("type", ["user", "guest"]).notNull();
|
|
});
|
|
}).then(() => {
|
|
return knex.schema.createTable("devices", (table) => {
|
|
table.bigIncrements("id").primary();
|
|
table.integer("user_id").notNull().references("users.id");
|
|
table.text("name");
|
|
table.text("device_id").notNull();
|
|
table.text("token").notNull();
|
|
|
|
table.unique(["user_id", "device_id"]);
|
|
});
|
|
});
|
|
};
|
|
|
|
module.exports.down = function(knex, Promise) {
|
|
return Promise.try(() => {
|
|
return knex.schema.dropTable("devices");
|
|
}).then(() => {
|
|
return knex.schema.dropTable("users");
|
|
});
|
|
}; |