host.model.js 586 B

1234567891011121314151617181920212223242526
  1. async function createHostTable(knex) {
  2. const hasTable = await knex.schema.hasTable("hosts");
  3. if (!hasTable) {
  4. await knex.schema.createTable("hosts", table => {
  5. table.increments("id").primary();
  6. table
  7. .string("address")
  8. .unique()
  9. .notNullable();
  10. table
  11. .boolean("banned")
  12. .notNullable()
  13. .defaultTo(false);
  14. table
  15. .integer("banned_by_id")
  16. .unsigned()
  17. .references("id")
  18. .inTable("users");
  19. table.timestamps(false, true);
  20. });
  21. }
  22. }
  23. module.exports = {
  24. createHostTable
  25. }