initial commit
This commit is contained in:
commit
4fc3bb0a01
202 changed files with 41729 additions and 0 deletions
25
database/migrations/acl_1_roles.ts
Normal file
25
database/migrations/acl_1_roles.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
import Config from '@ioc:Adonis/Core/Config'
|
||||
|
||||
export default class Roles extends BaseSchema {
|
||||
protected tableName = Config.get('rolePermission.role_table', 'roles')
|
||||
|
||||
public async up () {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name', 191).unique()
|
||||
table.string('slug', 191).nullable().unique()
|
||||
table.string('description', 191).nullable()
|
||||
|
||||
/**
|
||||
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||
*/
|
||||
table.timestamp('created_at', { useTz: true }).nullable()
|
||||
table.timestamp('updated_at', { useTz: true }).nullable()
|
||||
})
|
||||
}
|
||||
|
||||
public async down () {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
25
database/migrations/acl_2_permissions.ts
Normal file
25
database/migrations/acl_2_permissions.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
import Config from '@ioc:Adonis/Core/Config'
|
||||
|
||||
export default class Permissions extends BaseSchema {
|
||||
protected tableName = Config.get('rolePermission.permission_table', 'permissions')
|
||||
|
||||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name', 191).unique()
|
||||
table.string('slug', 191).nullable().unique()
|
||||
table.string('description', 191).nullable()
|
||||
|
||||
/**
|
||||
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||
*/
|
||||
table.timestamp('created_at', { useTz: true }).nullable()
|
||||
table.timestamp('updated_at', { useTz: true }).nullable()
|
||||
})
|
||||
}
|
||||
|
||||
public async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
32
database/migrations/acl_3_role_permissions.ts
Normal file
32
database/migrations/acl_3_role_permissions.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
import Config from '@ioc:Adonis/Core/Config'
|
||||
|
||||
export default class RolePermissions extends BaseSchema {
|
||||
protected tableName = Config.get('rolePermission.role_permission_table', 'role_permissions')
|
||||
|
||||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table
|
||||
.integer('role_id')
|
||||
.unsigned()
|
||||
.references('id')
|
||||
.inTable(Config.get('rolePermission.role_table', 'roles'))
|
||||
table
|
||||
.integer('permission_id')
|
||||
.unsigned()
|
||||
.references('id')
|
||||
.inTable(Config.get('rolePermission.permission_table', 'permissions'))
|
||||
|
||||
/**
|
||||
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||
*/
|
||||
table.timestamp('created_at', { useTz: true }).nullable()
|
||||
table.timestamp('updated_at', { useTz: true }).nullable()
|
||||
})
|
||||
}
|
||||
|
||||
public async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
32
database/migrations/acl_4_user_permissions.ts
Normal file
32
database/migrations/acl_4_user_permissions.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
import Config from '@ioc:Adonis/Core/Config'
|
||||
|
||||
export default class UserPermissions extends BaseSchema {
|
||||
protected tableName = Config.get('rolePermission.user_permission_table', 'user_permissions')
|
||||
|
||||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table
|
||||
.integer('user_id')
|
||||
.unsigned()
|
||||
.references('id')
|
||||
.inTable(Config.get('rolePermission.user_table', 'users'))
|
||||
table
|
||||
.integer('permission_id')
|
||||
.unsigned()
|
||||
.references('id')
|
||||
.inTable(Config.get('rolePermission.permission_table', 'permissions'))
|
||||
|
||||
/**
|
||||
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||
*/
|
||||
table.timestamp('created_at', { useTz: true }).nullable()
|
||||
table.timestamp('updated_at', { useTz: true }).nullable()
|
||||
})
|
||||
}
|
||||
|
||||
public async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
32
database/migrations/acl_5_user_roles.ts
Normal file
32
database/migrations/acl_5_user_roles.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||
import Config from '@ioc:Adonis/Core/Config'
|
||||
|
||||
export default class UserRoles extends BaseSchema {
|
||||
protected tableName = Config.get('rolePermission.user_role_table', 'user_roles')
|
||||
|
||||
public async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table
|
||||
.integer('user_id')
|
||||
.unsigned()
|
||||
.references('id')
|
||||
.inTable(Config.get('rolePermission.user_table', 'users'))
|
||||
table
|
||||
.integer('role_id')
|
||||
.unsigned()
|
||||
.references('id')
|
||||
.inTable(Config.get('rolePermission.role_table', 'roles'))
|
||||
|
||||
/**
|
||||
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||
*/
|
||||
table.timestamp('created_at', { useTz: true }).nullable()
|
||||
table.timestamp('updated_at', { useTz: true }).nullable()
|
||||
})
|
||||
}
|
||||
|
||||
public async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue