mirror of
https://github.com/pawelmalak/snippet-box.git
synced 2025-12-21 21:33:10 +01:00
46 lines
943 B
TypeScript
46 lines
943 B
TypeScript
import { DataTypes, Model } from 'sequelize';
|
|
import type { Migration } from '../';
|
|
import {
|
|
Snippet,
|
|
SnippetCreationAttributes
|
|
} from '../../typescript/interfaces';
|
|
|
|
const { INTEGER, STRING, DATE } = DataTypes;
|
|
|
|
export const up: Migration = async ({
|
|
context: queryInterface
|
|
}): Promise<void> => {
|
|
await queryInterface.createTable<Model<Snippet, SnippetCreationAttributes>>(
|
|
'snippets',
|
|
{
|
|
id: {
|
|
type: INTEGER,
|
|
allowNull: false,
|
|
primaryKey: true
|
|
},
|
|
title: {
|
|
type: STRING,
|
|
allowNull: false
|
|
},
|
|
language: {
|
|
type: STRING,
|
|
allowNull: false
|
|
},
|
|
createdAt: {
|
|
type: DATE,
|
|
allowNull: false
|
|
},
|
|
updatedAt: {
|
|
type: DATE,
|
|
allowNull: false
|
|
}
|
|
}
|
|
);
|
|
};
|
|
|
|
export const down: Migration = async ({
|
|
context: queryInterface
|
|
}): Promise<void> => {
|
|
await queryInterface.dropTable('snippets');
|
|
};
|