不要怂,就是干,撸起袖子干!

Commit 920a5c88 by VictorKunzler Committed by Sushant

docs(migrations): foreign key example (#11097)

1 parent a72a3f50
Showing with 33 additions and 0 deletions
......@@ -250,6 +250,39 @@ module.exports = {
};
```
The next is an example of a migration that has a foreign key. You can use references to specify a foreign key:
```js
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('Person', {
name: Sequelize.STRING,
isBetaMember: {
type: Sequelize.BOOLEAN,
defaultValue: false,
allowNull: false
},
userId: {
type: Sequelize.INTEGER,
references: {
model: {
tableName: 'users',
schema: 'schema'
}
key: 'id'
},
allowNull: false
},
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('Person');
}
}
```
### The `.sequelizerc` File
This is a special configuration file. It lets you specify various options that you would usually pass as arguments to CLI. Some scenarios where you can use it.
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!