Add initial project files
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'admins'
|
||||
|
||||
async up() {
|
||||
await this.schema.raw('DROP TYPE IF EXISTS admin_status_enum')
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id').notNullable()
|
||||
table.string('email').notNullable().unique()
|
||||
table.string('password').notNullable()
|
||||
table.string('first_name').nullable()
|
||||
table.string('last_name').nullable()
|
||||
table
|
||||
.enu('status', ['active', 'inactive'], {
|
||||
useNative: true,
|
||||
enumName: 'admin_status_enum',
|
||||
})
|
||||
.notNullable()
|
||||
.defaultTo('active')
|
||||
table.timestamp('created_at').notNullable()
|
||||
table.timestamp('updated_at').nullable()
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'auth_access_tokens'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table
|
||||
.integer('tokenable_id')
|
||||
.notNullable()
|
||||
.unsigned()
|
||||
.references('id')
|
||||
.inTable('admins')
|
||||
.onDelete('CASCADE')
|
||||
|
||||
table.string('type').notNullable()
|
||||
table.string('name').nullable()
|
||||
table.string('hash').notNullable()
|
||||
table.text('abilities').notNullable()
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
table.timestamp('last_used_at').nullable()
|
||||
table.timestamp('expires_at').nullable()
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'roles'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name').notNullable().unique()
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'permissions'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name').notNullable().unique()
|
||||
table.string('slug').notNullable().unique()
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'admin_roles'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.integer('role_id').unsigned().references('id').inTable('roles').onDelete('CASCADE')
|
||||
table.integer('admin_id').unsigned().references('id').inTable('admins').onDelete('CASCADE')
|
||||
table.unique(['role_id', 'admin_id'])
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'role_permissions'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.integer('role_id').unsigned().references('id').inTable('roles').onDelete('CASCADE')
|
||||
table.string('permission_slug').unsigned()
|
||||
table.unique(['role_id', 'permission_slug'])
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'web_pages'
|
||||
|
||||
async up() {
|
||||
this.schema.raw('DROP TYPE IF EXISTS web_page_status_enum')
|
||||
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table
|
||||
.enu('status', ['draft', 'published', 'unpublished'], {
|
||||
useNative: true,
|
||||
enumName: 'web_page_status_enum',
|
||||
})
|
||||
.notNullable()
|
||||
.defaultTo('draft')
|
||||
table
|
||||
.integer('draft_of_id')
|
||||
.unsigned()
|
||||
.nullable()
|
||||
.references('id')
|
||||
.inTable(this.tableName)
|
||||
.onDelete('CASCADE')
|
||||
table.string('locale', 16).notNullable()
|
||||
table.string('path').notNullable()
|
||||
table.string('group_key').notNullable()
|
||||
table.string('page_type').notNullable()
|
||||
table.string('title').notNullable()
|
||||
table.jsonb('hero').nullable()
|
||||
table.string('seo_title').notNullable().defaultTo('')
|
||||
table.text('seo_description').notNullable().defaultTo('')
|
||||
table.timestamp('published_at', { useTz: true }).nullable()
|
||||
table.timestamp('created_at', { useTz: true }).notNullable()
|
||||
table.timestamp('updated_at', { useTz: true }).notNullable()
|
||||
|
||||
table.index(['group_key', 'status'])
|
||||
table.index(['locale', 'path', 'status'])
|
||||
})
|
||||
|
||||
this.schema.raw(`
|
||||
CREATE UNIQUE INDEX web_pages_published_route_unique
|
||||
ON ${this.tableName} (locale, path)
|
||||
WHERE status = 'published'
|
||||
`)
|
||||
this.schema.raw(`
|
||||
CREATE UNIQUE INDEX web_pages_one_draft_per_page_unique
|
||||
ON ${this.tableName} (draft_of_id)
|
||||
WHERE draft_of_id IS NOT NULL
|
||||
`)
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
this.schema.raw('DROP TYPE IF EXISTS web_page_status_enum')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'web_components'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table
|
||||
.integer('page_id')
|
||||
.unsigned()
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('web_pages')
|
||||
.onDelete('CASCADE')
|
||||
table.string('type').notNullable()
|
||||
table.jsonb('data').notNullable()
|
||||
table.integer('sort_order').unsigned().notNullable().defaultTo(0)
|
||||
table.timestamp('created_at', { useTz: true }).notNullable()
|
||||
table.timestamp('updated_at', { useTz: true }).notNullable()
|
||||
|
||||
table.index(['page_id', 'sort_order'])
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'web_settings'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('locale', 16).notNullable().unique()
|
||||
table.jsonb('header').notNullable().defaultTo('{}')
|
||||
table.jsonb('footer').notNullable().defaultTo('{}')
|
||||
table.jsonb('legal').notNullable().defaultTo('{}')
|
||||
table.timestamp('created_at', { useTz: true }).notNullable()
|
||||
table.timestamp('updated_at', { useTz: true }).notNullable()
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user