Skip to content

Commit

Permalink
create migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-ng committed Mar 21, 2024
1 parent b0e1b09 commit 07cbfd5
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { DataTypes } from 'sequelize';

import { Migration } from "../umzug";

const TABLE_NAME = "users";

export const up: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().addColumn(TABLE_NAME, 'permission', {
type: DataTypes.ENUM('VP Talent', 'Eteam', 'Engineering', 'Product', 'Design', 'Reviewers'),
allowNull: false,
defaultValue: 'Reviewers'
});

await sequelize.getQueryInterface().changeColumn(TABLE_NAME, 'role', {
type: DataTypes.ENUM(), // TODO: Add roles
allowNull: false,
});
};

export const down: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().removeColumn(TABLE_NAME, 'permission');

await sequelize.getQueryInterface().changeColumn(TABLE_NAME, 'role', {
type: DataTypes.ENUM('User', 'Admin'),
allowNull: false,
});
};

0 comments on commit 07cbfd5

Please sign in to comment.