You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
977 B
35 lines
977 B
11 months ago
|
/**
|
||
|
* @param { import("knex").Knex } knex
|
||
|
* @returns { Promise<void> }
|
||
|
*/
|
||
|
const up = (knex) => {
|
||
|
return knex.schema
|
||
|
.createTable('maps', (table) => {
|
||
|
table.increments().primary()
|
||
|
table.string('name').notNullable().unique()
|
||
|
table.timestamp('created_at').defaultTo(knex.fn.now())
|
||
|
table.timestamp('updated_at').defaultTo(knex.fn.now())
|
||
|
})
|
||
|
.createTable('map_points', (table) => {
|
||
|
table.increments().primary()
|
||
|
table.string('name')
|
||
|
table.string('notes')
|
||
|
table.point('location')
|
||
|
table.timestamp('created_at').defaultTo(knex.fn.now())
|
||
|
table.timestamp('updated_at').defaultTo(knex.fn.now())
|
||
|
table.integer('map_id').references('id').inTable('maps')
|
||
|
})
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param { import("knex").Knex } knex
|
||
|
* @returns { Promise<void> }
|
||
|
*/
|
||
|
const down = (knex) => {
|
||
|
return knex.schema
|
||
|
.raw('DROP TABLE maps CASCADE')
|
||
|
.dropTable('map_points')
|
||
|
}
|
||
|
|
||
|
export { up, down }
|