Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Add seeds #161

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"express": "^4.17.1",
"express-async-handler": "^1.1.4",
"express-response-errors": "^1.0.4",
"faker": "^4.1.0",
"fork-ts-checker-webpack-plugin": "^1.5.1",
"module-alias": "^2.2.2",
"morgan": "^1.9.1",
Expand All @@ -63,6 +64,7 @@
"@testing-library/react": "^9.3.0",
"@types/bluebird": "^3.5.28",
"@types/express": "^4.17.1",
"@types/faker": "^4.1.7",
"@types/jest": "^24.0.19",
"@types/morgan": "^1.7.37",
"@types/next": "^8.0.6",
Expand Down
2 changes: 1 addition & 1 deletion server/migrations/20191025082945-create-chapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ module.exports = {
});
},
down: (queryInterface, _sequelize) => {
return queryInterface.dropTable('Chapters');
return queryInterface.dropTable('chapters');
},
};
4 changes: 2 additions & 2 deletions server/models/Chapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DataType,
} from 'sequelize-typescript';

@Table
@Table({ tableName: 'chapters' })
export class Chapter extends Model<Chapter> {
@Column
name!: string;
Expand All @@ -19,7 +19,7 @@ export class Chapter extends Model<Chapter> {
category!: string;

@Column(DataType.JSON)
details!: any;
details: any;

@CreatedAt
@Column
Expand Down
25 changes: 25 additions & 0 deletions server/seeders/20191108094637-chapters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const faker = require('faker');

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.bulkInsert(
'chapters',
[
{
name: faker.name.title(),
description: faker.lorem.paragraph(),
category: faker.lorem.word(),
created_at: new Date(),
updated_at: new Date(),
},
],
{},
);
},

down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('chapters', null, {});
},
};