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

Commit ed1d28b8 by Vladlen Committed by Sushant

docs(migrations): Simplify CLI Call (#10201)

1 parent f2cafcc4
Showing with 11 additions and 11 deletions
...@@ -17,7 +17,7 @@ $ npm install --save sequelize-cli ...@@ -17,7 +17,7 @@ $ npm install --save sequelize-cli
To create an empty project you will need to execute `init` command To create an empty project you will need to execute `init` command
```bash ```bash
$ node_modules/.bin/sequelize init $ npx sequelize init
``` ```
This will create following folders This will create following folders
...@@ -71,7 +71,7 @@ We will use `model:generate` command. This command requires two options ...@@ -71,7 +71,7 @@ We will use `model:generate` command. This command requires two options
Let's create a model named `User`. Let's create a model named `User`.
```bash ```bash
$ node_modules/.bin/sequelize model:generate --name User --attributes firstName:string,lastName:string,email:string $ npx sequelize model:generate --name User --attributes firstName:string,lastName:string,email:string
``` ```
This will do following This will do following
...@@ -85,7 +85,7 @@ This will do following ...@@ -85,7 +85,7 @@ This will do following
Until this step, we haven't inserted anything into the database. We have just created required model and migration files for our first model `User`. Now to actually create that table in database you need to run `db:migrate` command. Until this step, we haven't inserted anything into the database. We have just created required model and migration files for our first model `User`. Now to actually create that table in database you need to run `db:migrate` command.
```bash ```bash
$ node_modules/.bin/sequelize db:migrate $ npx sequelize db:migrate
``` ```
This command will execute these steps: This command will execute these steps:
...@@ -100,13 +100,13 @@ Now our table has been created and saved in database. With migration you can rev ...@@ -100,13 +100,13 @@ Now our table has been created and saved in database. With migration you can rev
You can use `db:migrate:undo`, this command will revert most recent migration. You can use `db:migrate:undo`, this command will revert most recent migration.
```bash ```bash
$ node_modules/.bin/sequelize db:migrate:undo $ npx sequelize db:migrate:undo
``` ```
You can revert back to initial state by undoing all migrations with `db:migrate:undo:all` command. You can also revert back to a specific migration by passing its name in `--to` option. You can revert back to initial state by undoing all migrations with `db:migrate:undo:all` command. You can also revert back to a specific migration by passing its name in `--to` option.
```bash ```bash
$ node_modules/.bin/sequelize db:migrate:undo:all --to XXXXXXXXXXXXXX-create-posts.js $ npx sequelize db:migrate:undo:all --to XXXXXXXXXXXXXX-create-posts.js
``` ```
### Creating First Seed ### Creating First Seed
...@@ -117,7 +117,7 @@ To manage all data migrations you can use seeders. Seed files are some change in ...@@ -117,7 +117,7 @@ To manage all data migrations you can use seeders. Seed files are some change in
Let's create a seed file which will add a demo user to our `User` table. Let's create a seed file which will add a demo user to our `User` table.
```bash ```bash
$ node_modules/.bin/sequelize seed:generate --name demo-user $ npx sequelize seed:generate --name demo-user
``` ```
This command will create a seed file in `seeders` folder. File name will look something like `XXXXXXXXXXXXXX-demo-user.js`. It follows the same `up / down` semantics as the migration files. This command will create a seed file in `seeders` folder. File name will look something like `XXXXXXXXXXXXXX-demo-user.js`. It follows the same `up / down` semantics as the migration files.
...@@ -147,7 +147,7 @@ module.exports = { ...@@ -147,7 +147,7 @@ module.exports = {
In last step you have create a seed file. It's still not committed to database. To do that we need to run a simple command. In last step you have create a seed file. It's still not committed to database. To do that we need to run a simple command.
```bash ```bash
$ node_modules/.bin/sequelize db:seed:all $ npx sequelize db:seed:all
``` ```
This will execute that seed file and you will have a demo user inserted into `User` table. This will execute that seed file and you will have a demo user inserted into `User` table.
...@@ -160,19 +160,19 @@ Seeders can be undone if they are using any storage. There are two commands avai ...@@ -160,19 +160,19 @@ Seeders can be undone if they are using any storage. There are two commands avai
If you wish to undo most recent seed If you wish to undo most recent seed
```bash ```bash
node_modules/.bin/sequelize db:seed:undo $ npx sequelize db:seed:undo
``` ```
If you wish to undo a specific seed If you wish to undo a specific seed
```bash ```bash
node_modules/.bin/sequelize db:seed:undo --seed name-of-seed-as-in-data $ npx sequelize db:seed:undo --seed name-of-seed-as-in-data
``` ```
If you wish to undo all seeds If you wish to undo all seeds
```bash ```bash
node_modules/.bin/sequelize db:seed:undo:all $ npx sequelize db:seed:undo:all
``` ```
## Advance Topics ## Advance Topics
...@@ -514,7 +514,7 @@ As an alternative to the `--config` option with configuration files defining you ...@@ -514,7 +514,7 @@ As an alternative to the `--config` option with configuration files defining you
use the `--url` option to pass in a connection string. For example: use the `--url` option to pass in a connection string. For example:
```bash ```bash
$ node_modules/.bin/sequelize db:migrate --url 'mysql://root:password@mysql_host.com/database_name' $ npx sequelize db:migrate --url 'mysql://root:password@mysql_host.com/database_name'
``` ```
### Connecting over SSL ### Connecting over SSL
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!