Last active
May 14, 2021 20:12
-
-
Save carvalholeo/26746c8d08e4de655601f1400f834d2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Knex from "knex"; | |
export async function up(knex: Knex): Promise<void> { | |
return await knex.schema.createTable("permissions", table => { | |
table.increments("id") | |
.primary(); | |
table.string("name") | |
.notNullable(); | |
table.boolean("create_own_records") | |
.notNullable() | |
.defaultTo(true); | |
table.boolean("create_roles_permissions") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("create_system_users") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("create_third_party_records") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_access_logs") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_customers_users") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_own_records") | |
.notNullable() | |
.defaultTo(true); | |
table.boolean("read_system_configs") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_system_log") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_system_users") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_third_party_records") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_user_informations") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("read_user_roles") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("update_customers_users") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("update_own_records") | |
.notNullable() | |
.defaultTo(true); | |
table.boolean("update_roles_permissions") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("update_system_configs") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("update_system_users") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("update_third_party_records") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("update_user_email") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("update_user_roles") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("delete_own_records") | |
.notNullable() | |
.defaultTo(true); | |
table.boolean("delete_third_party_records") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("able_disable_user") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("remove_2fa") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("reset_password") | |
.notNullable() | |
.defaultTo(false); | |
table.boolean("is_root_admin") | |
.notNullable() | |
.defaultTo(false); | |
table.timestamps() | |
.notNullable() | |
.defaultTo(knex.raw("CURRENT_TIMESTAMP")); | |
table.index("id"); | |
}); | |
} | |
export async function down(knex: Knex): Promise<void> { | |
return await knex.schema.dropTable("permissions"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment