nfp_sites/migrations/20190219105500_base.js

111 lines
2.9 KiB
JavaScript
Raw Normal View History

2019-02-19 11:34:52 +00:00
/* eslint-disable */
exports.up = function up(knex, Promise) {
return Promise.all([
knex.schema.createTable('staff', function(table) {
table.increments()
table.text('email')
table.text('fullname')
table.text('password')
2019-02-19 11:34:52 +00:00
table.boolean('is_deleted')
.notNullable()
.default(false)
table.integer('level')
.notNullable()
.defaultTo(1)
table.timestamps()
})
.then(pass =>
knex('staff').insert({
email: 'jonatan@nilsson.is',
fullname: 'Admin',
level: 100,
})
),
knex.schema.createTable('media', function(table) {
table.increments()
table.text('filename')
table.text('filetype')
table.text('small_image')
table.text('medium_image')
table.text('large_image')
table.text('org_image')
2019-02-19 11:34:52 +00:00
table.integer('size')
2019-09-13 13:33:10 +00:00
table.integer('staff_id')
2019-02-19 11:34:52 +00:00
.references('staff.id')
2019-09-13 13:33:10 +00:00
table.boolean('is_deleted')
.notNullable()
.default(false)
table.timestamps()
}),
knex.schema.createTable('pages', function(table) {
table.increments()
table.integer('staff_id')
.references('staff.id')
table.integer('parent_id')
.references('pages.id')
table.text('name')
table.text('path')
table.text('description')
table.integer('banner_id')
.references('media.id')
.defaultTo(null)
table.integer('media_id')
.references('media.id')
.defaultTo(null)
table.boolean('is_deleted')
.notNullable()
.default(false)
table.timestamps()
}),
knex.schema.createTable('articles', function(table) {
table.increments()
table.integer('staff_id')
.references('staff.id')
table.integer('parent_id')
.references('pages.id')
table.text('name')
table.text('path')
table.text('description')
table.integer('banner_id')
.references('media.id')
.defaultTo(null)
table.integer('media_id')
.references('media.id')
.defaultTo(null)
table.boolean('is_deleted')
.notNullable()
.default(false)
2019-10-02 00:16:11 +00:00
table.timestamp('published_at')
.defaultTo(knex.fn.now())
table.boolean('is_featured')
.notNullable()
.default(false)
2019-09-13 13:33:10 +00:00
table.timestamps()
}),
knex.schema.createTable('files', function(table) {
table.increments()
table.integer('article_id')
2019-09-14 19:03:38 +00:00
.references('articles.id')
2019-09-13 13:33:10 +00:00
table.text('filename')
table.text('filetype')
2019-09-14 19:03:38 +00:00
table.text('path')
2019-09-13 13:33:10 +00:00
table.integer('size')
2019-02-19 11:34:52 +00:00
table.integer('staff_id')
.references('staff.id')
2019-09-14 19:03:38 +00:00
table.jsonb('meta')
2019-02-19 11:34:52 +00:00
table.boolean('is_deleted')
.notNullable()
.default(false)
table.timestamps()
}),
])
}
exports.down = function down(knex, Promise) {
return Promise.all([
knex.schema.dropTable('media'),
knex.schema.dropTable('staff'),
])
}