Вы должны использовать Sequelize Command-Line Interface (CLI) , тогда вы можете использовать db:create
и db:drop
независимо от того, какую СУБД вы используете.
Вот использование, Я проверяю его, используя postgres:9.6
:
☁ node-sequelize-examples [master] npx sequelize-cli db:drop
Sequelize CLI [Node: 10.16.2, CLI: 5.5.1, ORM: 5.21.3]
Loaded configuration file "src/config/config.js".
Using environment "development".
Executing (default): DROP DATABASE "node-sequelize-examples"
Database node-sequelize-examples dropped.
☁ node-sequelize-examples [master] npx sequelize-cli db:create
Sequelize CLI [Node: 10.16.2, CLI: 5.5.1, ORM: 5.21.3]
Loaded configuration file "src/config/config.js".
Using environment "development".
Executing (default): CREATE DATABASE "node-sequelize-examples"
Database node-sequelize-examples created.
src/config/config.js
:
module.exports = {
development: {
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
host: process.env.POSTGRES_HOST,
port: process.env.POSTGRES_PORT,
dialect: 'postgres',
logging: console.log,
},
test: {
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
host: process.env.POSTGRES_HOST,
port: process.env.POSTGRES_PORT,
dialect: 'postgres',
},
production: {
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
host: process.env.POSTGRES_HOST,
port: process.env.POSTGRES_PORT,
dialect: 'postgres',
},
};
Проверьте базу данных, используя psql
:
# psql -U testuser node-sequelize-examples
psql (9.6.11)
Type "help" for help.
node-sequelize-examples=# \d
No relations found.