Merge pull request #944 from automatisch/user-role
feat: Introduce role column to user model
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
import { Knex } from 'knex';
|
||||||
|
|
||||||
|
export async function up(knex: Knex): Promise<void> {
|
||||||
|
return knex.schema.table('users', async (table) => {
|
||||||
|
table.string('role');
|
||||||
|
|
||||||
|
await knex('users').update({ role: 'admin' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex: Knex): Promise<void> {
|
||||||
|
return knex.schema.table('users', (table) => {
|
||||||
|
table.dropColumn('role');
|
||||||
|
});
|
||||||
|
}
|
@@ -0,0 +1,13 @@
|
|||||||
|
import { Knex } from 'knex';
|
||||||
|
|
||||||
|
export async function up(knex: Knex): Promise<void> {
|
||||||
|
return knex.schema.alterTable('users', (table) => {
|
||||||
|
table.string('role').notNullable().alter();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex: Knex): Promise<void> {
|
||||||
|
return knex.schema.alterTable('users', (table) => {
|
||||||
|
table.string('role').nullable().alter();
|
||||||
|
});
|
||||||
|
}
|
@@ -10,6 +10,7 @@ class User extends Base {
|
|||||||
id!: string;
|
id!: string;
|
||||||
email!: string;
|
email!: string;
|
||||||
password!: string;
|
password!: string;
|
||||||
|
role: string;
|
||||||
connections?: Connection[];
|
connections?: Connection[];
|
||||||
flows?: Flow[];
|
flows?: Flow[];
|
||||||
steps?: Step[];
|
steps?: Step[];
|
||||||
@@ -25,6 +26,7 @@ class User extends Base {
|
|||||||
id: { type: 'string', format: 'uuid' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 },
|
email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 },
|
||||||
password: { type: 'string', minLength: 1, maxLength: 255 },
|
password: { type: 'string', minLength: 1, maxLength: 255 },
|
||||||
|
role: { type: 'string', enum: ['admin', 'user'] },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user