Skip to content

Commit

Permalink
feat: use snake_case for table name (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Duy Cuong Tran authored Oct 29, 2020
1 parent d7be30d commit eb15c4e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-kit",
"version": "1.1.0",
"version": "1.2.0",
"main": "src/index.ts",
"description": "🍣 A Node kit with TypeScript, GraphQL, Sequelize, PostgreSQL and awesome tools.",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/migrations/20200605151403_create_category.migration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QueryInterface, DataTypes } from 'sequelize';

const migration = {
up: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.createTable('categories', {
up: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.createTable('category', {
id: {
type: DataTypes.UUID,
primaryKey: true,
Expand All @@ -22,7 +22,7 @@ const migration = {
}, {
transaction: t,
})),
down: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.dropTable('categories', { transaction: t })),
down: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.dropTable('category', { transaction: t })),
};

export default migration;
6 changes: 3 additions & 3 deletions src/migrations/20200605151452_create_cat.migration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { QueryInterface, DataTypes } from 'sequelize';

const migration = {
up: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.createTable('cats', {
up: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.createTable('cat', {
id: {
type: DataTypes.UUID,
primaryKey: true,
Expand All @@ -17,7 +17,7 @@ const migration = {
category_id: {
type: DataTypes.UUID,
references: {
model: 'categories',
model: 'category',
key: 'id',
},
},
Expand All @@ -33,7 +33,7 @@ const migration = {
}, {
transaction: t,
})),
down: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.dropTable('cats', { transaction: t })),
down: (queryInterface: QueryInterface) => queryInterface.sequelize.transaction((t) => queryInterface.dropTable('cat', { transaction: t })),
};

export default migration;
4 changes: 2 additions & 2 deletions src/models/cat.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ const initModel = (sequelize: Sequelize) => {
categoryId: {
type: DataTypes.UUID,
references: {
model: 'categories',
model: 'category',
key: 'id',
},
},
}, {
sequelize,
underscored: true,
paranoid: true,
tableName: 'cats',
tableName: 'cat',
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/models/category.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const initModel = (sequelize: Sequelize) => {
sequelize,
underscored: true,
paranoid: true,
tableName: 'categories',
tableName: 'category',
});
};

Expand Down

0 comments on commit eb15c4e

Please sign in to comment.