I’m running yarn sequelize db:migrate
to create the table in the database using a postgres image in the docker and returns the following message:
JavaScript
x
15
15
1
mateus @ fariasmateuss: ~ / Projects / gobarber / server $ yarn sequelize db: migrate
2
yarn run v1.22.4
3
4
$ /home/mateus/Projects/gobarber/server/node_modules/.bin/sequelize db: migrate
5
6
Sequelize CLI [Node: 12.17.0, CLI: 6.0.0, ORM: 6.2.0]
7
8
Loaded configuration file "src / config / database.js".
9
== 20200627041347-create-users: migrating =======
10
11
ERROR: Cannot read property 'type' of undefined
12
13
error Command failed with exit code 1.
14
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command
15
Configuration of the .sequelizerc
file:
JavaScript
1
9
1
const {resolve} = require ('path');
2
3
module.exports = {
4
config: resolves (__ dirname, 'src', 'config', 'database.js'),
5
'models-path': resolves (__ dirname, 'src', 'app', 'models'),
6
'migrations-path': resolves (__ dirname, 'src', 'database', 'migrations'),
7
'seeders-path': resolves (__ dirname, 'src', 'database', 'seeds'),
8
};
9
Code to create the table in the file migrations.js
:
JavaScript
1
43
43
1
module.exports = {
2
up: (queryInterface, Sequelize) => {
3
return queryInterface.createTable ('users', {
4
id: {
5
type: Sequelize.INTEGER,
6
allowNull: false,
7
autoIncrement: true,
8
primaryKey: true,
9
},
10
name: {
11
type: Sequelize.STRING,
12
allowNull: false,
13
},
14
email: {
15
type: Sequelize.STRING,
16
allowNull: false,
17
unique: true,
18
},
19
password_hash: {
20
type: Sequelize.STRING,
21
allowNull: false,
22
},
23
provider: {
24
type: Sequelize.BOOLEAN,
25
defaultValues: false,
26
allowNull: false,
27
},
28
created_at: {
29
type: Sequelize.DATA,
30
allowNull: false,
31
},
32
updated_at: {
33
type: Sequelize.DATA,
34
allowNull: false,
35
},
36
});
37
},
38
39
down: (queryInterface) => {
40
return queryInterface.dropTable ('users');
41
},
42
};
43
OS: Linux Focal Fossa 20.04 LTS
Would anyone know what the possible solution would be?
Advertisement
Answer
Error seems to be a typo, the type
for Sequelize.DATA
vs Sequelize.DATE
.
Here are the valid data types.