@jsgurucompany/jsg-nestjs-common
Version:
Initial README.md
41 lines • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.down = exports.up = void 0;
const sequelize_1 = require("sequelize");
const uuid_1 = require("uuid");
const up = async ({ context }) => {
await context.createTable('examples_types', {
id: {
type: sequelize_1.DataTypes.UUID,
defaultValue: sequelize_1.DataTypes.UUIDV4,
allowNull: false,
primaryKey: true,
},
name: {
type: sequelize_1.DataTypes.STRING,
allowNull: false,
},
createdAt: {
type: sequelize_1.DataTypes.DATE,
allowNull: false,
defaultValue: sequelize_1.default.literal('CURRENT_TIMESTAMP'),
},
updatedAt: {
type: sequelize_1.DataTypes.DATE,
allowNull: false,
defaultValue: sequelize_1.default.literal('CURRENT_TIMESTAMP'),
},
});
await context.bulkInsert('examples_types', [1, 2, 3, 4].map((num) => ({
id: (0, uuid_1.v4)(),
name: `Test Example Type #${num}`,
createdAt: new Date(),
updatedAt: new Date(),
})));
};
exports.up = up;
const down = async ({ context }) => {
await context.dropTable('examples_types');
};
exports.down = down;
//# sourceMappingURL=2022.03.08T13.43.52.create-examples-types-table.migration.js.map