Skip to content

Commit a6290fd

Browse files
1 parent e731a26 commit a6290fd

File tree

6 files changed

+352
-242
lines changed

6 files changed

+352
-242
lines changed

.github/ISSUE_TEMPLATE.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
3+
Please note this is an issue tracker, not a support forum.
4+
For general questions, please use StackOverflow or Slack.
5+
6+
For bugs, please fill out the template below.
7+
8+
-->
9+
10+
## What you are doing?
11+
<!-- Post a minimal, self-contained code sample that reproduces the issue, include config and migration file(s) -->
12+
13+
```js
14+
// code here
15+
```
16+
17+
## What do you expect to happen?
18+
_I wanted Foo!_
19+
20+
## What is actually happening?
21+
_But the output was bar!_
22+
23+
_Output, either JSON or SQL_
24+
25+
26+
__Dialect:__ mysql / postgres / sqlite / mssql / any
27+
__Database version:__ XXX
28+
__Sequelize CLI version:__ XXX
29+
__Sequelize version:__ XXX

CONTRIBUTING.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing
2+
3+
Sequelize CLI is entirely driven by community contributions. Any little contribution with code or documentation work helps us keeping this project running.
4+
5+
You can help us in various ways
6+
7+
## Reporting Bugs
8+
9+
### Security Issues
10+
11+
Although CLI is never supposed to be web facing, we still want to fix any security issues. Please contact project maintainers **privately**. You can find more information [here](https://github.com/sequelize/sequelize/blob/master/CONTACT.md).
12+
13+
### General Issues or Feature Requests
14+
15+
Github issues should follow specified template. When you start creating a new issue, an empty template will be already filled.
16+
17+
Please make sure issue you are reporting is strictly related to Sequelize CLI.
18+
19+
If you want to propose new features to Sequelize CLI, you may ignore issue template. You still need to clearly state new feature. Feature request should give various examples, API suggestions and references to support idea behind it.
20+
21+
## Fixing Bugs or Implementing Features
22+
23+
### Preparing your environment
24+
25+
Start with cloning Sequelize CLI repo
26+
27+
```bash
28+
$ git clone [email protected]:sequelize/cli.git
29+
30+
$ git clone https://github.com/sequelize/cli.git # Using HTTPS
31+
```
32+
33+
Make sure you have all required dependencies, you will need
34+
35+
- Node v4 or above
36+
- NPM v3 or above
37+
38+
Now go to cloned repository folder
39+
40+
```bash
41+
$ cd /path/to/cloned/repository
42+
```
43+
44+
Install required modules
45+
46+
```bash
47+
$ npm install
48+
```
49+
50+
### Running tests
51+
52+
By default CLI use SQLite, which requires no database configuration. We use Babel to build CLI. Running default test command will automatically build it for you.
53+
54+
```bash
55+
$ npm test
56+
```
57+
58+
Test can take about 7 to 10 minutes to finish, subjected to hardware configuration.
59+
60+
## Improving Documentation
61+
62+
If you want to improve or expand our documentation you can start with documentation in `/docs` folder of this repository.
63+
64+
You can also help by improving [Migration section](http://docs.sequelizejs.com/manual/tutorial/migrations.html). Please read more about contributing to Sequelize Docs [here](https://github.com/sequelize/sequelize/blob/master/CONTRIBUTING.DOCS.md)

README.md

+30-238
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
1-
# sequelize/cli [![Build Status](https://travis-ci.org/sequelize/cli.svg?branch=master)](https://travis-ci.org/sequelize/cli) [![Greenkeeper badge](https://badges.greenkeeper.io/sequelize/cli.svg)](https://greenkeeper.io/)
1+
# sequelize/cli [![npm version](https://badge.fury.io/js/sequelize-cli.svg)](https://badge.fury.io/js/sequelize-cli) [![Build Status](https://travis-ci.org/sequelize/cli.svg?branch=master)](https://travis-ci.org/sequelize/cli) [![Greenkeeper badge](https://badges.greenkeeper.io/sequelize/cli.svg)](https://greenkeeper.io/)
22

33
The Sequelize Command Line Interface (CLI)
44

5-
## Sequelize Support
6-
7-
In current v3 release CLI generate migration/models which follow Sequelize v3 format, CLI will work with Sequelize v4 in most cases but migration/model skeleton is still generated to support v3.
8-
9-
Full support for Sequelize v4 will be coming soon with [Sequelize CLI v4](https://github.com/sequelize/cli/issues/441)
5+
## Table of Contents
6+
- [Installation](#installation)
7+
- [Contributing](#contributing)
8+
- [Sequelize Support](#sequelize-support)
9+
- [Documentation](#documentation)
1010

1111
## Installation
1212

13-
Install this globally and you'll have access to the `sequelize` command anywhere on your system.
13+
### Globally
14+
Install CLI globally with
1415

1516
```bash
1617
$ npm install -g sequelize-cli
1718
```
1819

19-
or install it locally to your `node_modules` folder
20+
Now you can run CLI using following command anywhere
21+
22+
```bash
23+
$ sequelize
24+
```
25+
26+
### Locally
27+
Install CLI locally to your `node_modules` folder with
2028

2129
```bash
2230
$ npm install --save sequelize-cli
2331
```
24-
## Global Install Usage
32+
33+
You should be able to run CLI with
2534

2635
```bash
27-
$ sequelize
36+
$ node_modules/.bin/sequelize
2837
```
2938

39+
### Usage
3040
```
3141
Sequelize CLI [Node: 6.11.2, CLI: 3.0.0, ORM: 4.8.0]
3242
@@ -54,238 +64,20 @@ Options:
5464
--help Show help [boolean]
5565
```
5666

57-
## Local Install Usage
58-
59-
```
60-
$ node_modules/.bin/sequelize [--HARMONY-FLAGS]
61-
```
62-
63-
## Options
64-
65-
The manuals will show all the flags and options which are available for the respective tasks.
66-
If you find yourself in a situation where you always define certain flags in order to
67-
make the CLI compliant to your project, you can move those definitions also into a file called
68-
`.sequelizerc`. The file will get `require`d if available and can therefore be either a JSON file
69-
or a Node.JS script that exports a hash.
70-
71-
### Example for a Node.JS script
72-
73-
```js
74-
var path = require('path')
75-
76-
module.exports = {
77-
'config': path.resolve('config', 'database.json'),
78-
'migrations-path': path.resolve('db', 'migrate')
79-
}
80-
```
81-
82-
This will configure the CLI to always treat `config/database.json` as config file and
83-
`db/migrate` as the directory for migrations.
84-
85-
### Configuration file
86-
87-
By default the CLI will try to use the file `config/config.js` and `config/config.json`. You can modify that path either via the `--config` flag or via the option mentioned earlier. Here is how a configuration file might look like (this is the one that `sequelize init` generates):
88-
89-
```json
90-
{
91-
"development": {
92-
"username": "root",
93-
"password": null,
94-
"database": "database_development",
95-
"host": "127.0.0.1",
96-
"dialect": "mysql"
97-
},
98-
"test": {
99-
"username": "root",
100-
"password": null,
101-
"database": "database_test",
102-
"host": "127.0.0.1",
103-
"dialect": "mysql"
104-
},
105-
"production": {
106-
"username": "root",
107-
"password": null,
108-
"database": "database_production",
109-
"host": "127.0.0.1",
110-
"dialect": "mysql"
111-
}
112-
}
113-
```
114-
115-
The properties can also be combined to a `url`:
116-
117-
```json
118-
{
119-
"development": {
120-
"url": "mysql://root:password@mysql_host.com/database_name",
121-
"dialect": "mysql"
122-
}
123-
}
124-
```
125-
126-
In case of a JS file it obviously needs to `module.exports` the object.
127-
Optionally, it's possible to put all the configuration to the `url` option. The format is explained in the section below.
128-
129-
### Configuration Connection String
130-
131-
As an alternative to the `--config` option with configuration files defining your database, you can
132-
use the `--url` option to pass in a connection string. For example:
133-
134-
`sequelize db:migrate --url 'mysql://root:password@mysql_host.com/database_name'`
135-
136-
### Configuration Connection Environment Variable
137-
138-
Another possibility is to store the URL in an environment variable and to tell
139-
the CLI to lookup a certain variable during runtime. Let's assume you have an
140-
environment variable called `DB_CONNECTION_STRING` which stores the value
141-
`mysql://root:password@mysql_host.com/database_name`. In order to make the CLI
142-
use it, you have to use declare it in your config file:
143-
144-
```json
145-
{
146-
"production": {
147-
"use_env_variable": "DB_CONNECTION_STRING"
148-
}
149-
}
150-
```
151-
152-
With v2.0.0 of the CLI you can also just directly access the environment variables inside the `config/config.js`:
67+
## Contributing
15368

154-
```js
155-
module.exports = {
156-
"production": {
157-
"hostname": process.env.DB_HOSTNAME
158-
}
159-
}
160-
```
161-
162-
### Storage
163-
164-
There are three types of storage that you can use: `sequelize`, `json`, and `none`.
165-
166-
- `sequelize` : stores migrations and seeds in a table on the sequelize database
167-
- `json` : stores migrations and seeds on a json file
168-
- `none` : does not store any migration/seed
169-
170-
171-
#### Migration
172-
173-
By default the CLI will create a table in your database called `SequelizeMeta` containing an entry
174-
for each executed migration. To change this behavior, there are three options you can add to the
175-
configuration file. Using `migrationStorage`, you can choose the type of storage to be used for
176-
migrations. If you choose `json`, you can specify the path of the file using `migrationStoragePath`
177-
or the CLI will write to the file `sequelize-meta.json`. If you want to keep the information in the
178-
database, using `sequelize`, but want to use a different table, you can change the table name using
179-
`migrationStorageTableName`.
180-
181-
```json
182-
{
183-
"development": {
184-
"username": "root",
185-
"password": null,
186-
"database": "database_development",
187-
"host": "127.0.0.1",
188-
"dialect": "mysql",
189-
190-
// Use a different storage type. Default: sequelize
191-
"migrationStorage": "json",
192-
193-
// Use a different file name. Default: sequelize-meta.json
194-
"migrationStoragePath": "sequelizeMeta.json",
195-
196-
// Use a different table name. Default: SequelizeMeta
197-
"migrationStorageTableName": "sequelize_meta"
198-
}
199-
}
200-
```
201-
202-
NOTE: The `none` storage is not recommended as a migration storage. If you decide to use it, be
203-
aware of the implications of having no record of what migrations did or didn't run.
204-
205-
206-
#### Seed
207-
208-
By default the CLI will not save any seed that is executed. If you choose to change this behavior (!),
209-
you can use `seederStorage` in the configuration file to change the storage type. If you choose `json`,
210-
you can specify the path of the file using `seederStoragePath` or the CLI will write to the file
211-
`sequelize-data.json`. If you want to keep the information in the database, using `sequelize`, you can
212-
specify the table name using `seederStorageTableName`, or it will default to `SequelizeData`.
213-
214-
```json
215-
{
216-
"development": {
217-
"username": "root",
218-
"password": null,
219-
"database": "database_development",
220-
"host": "127.0.0.1",
221-
"dialect": "mysql",
222-
// Use a different storage. Default: none
223-
"seederStorage": "json",
224-
// Use a different file name. Default: sequelize-data.json
225-
"seederStoragePath": "sequelizeData.json",
226-
// Use a different table name. Default: SequelizeData
227-
"seederStorageTableName": "sequelize_data"
228-
}
229-
}
230-
```
69+
Sequelize CLI is always looking for contributions. You can help us with fixing bugs, reporting bugs or improving documentation.
23170

71+
Please read [contributing documentation](CONTRIBUTING.md)
23272

233-
### Dialect specific options
234-
235-
In order to pass options to the underlying database connectors, you can add the property `dialectOptions`
236-
to your configuration like this:
237-
238-
```js
239-
var fs = require('fs');
240-
241-
module.exports = {
242-
development: {
243-
dialect: 'mysql',
244-
dialectOptions: {
245-
ssl: {
246-
ca: fs.readFileSync(__dirname + '/mysql-ca.crt')
247-
}
248-
}
249-
}
250-
};
251-
```
252-
253-
### Schema migration
254-
255-
Sequelize CLI continue to use schema from `v2` and fully compatible with `v2`. If you are still using old schema from pre `v2`, use `v2` to upgrade to current schema with `db:migrate:old_schema`
256-
257-
#### Timestamps
258-
259-
Since v2.8.0 the CLI supports a adding timestamps to the schema for saving the executed migrations. You can opt-in for timestamps by running the following command:
260-
261-
```bash
262-
$ sequelize db:migrate:schema:timestamps:add
263-
```
264-
265-
### The migration schema
266-
267-
The CLI uses [umzug](https://github.com/sequelize/umzug) and its migration schema. This means a migration has to look like this:
268-
269-
```js
270-
"use strict";
271-
272-
module.exports = {
273-
up: function(queryInterface, Sequelize, done) {
274-
done();
275-
},
276-
277-
down: function(queryInterface) {
278-
return new Promise(function (resolve, reject) {
279-
resolve();
280-
});
281-
}
282-
};
283-
```
73+
## Sequelize Support
28474

285-
Please note that you can either return a Promise or call the third argument of the function once your asynchronous logic was executed. If you pass something to the callback function (the `done` function) it will be treated as erroneous execution.
75+
CLI v3 fully supports Sequelize v3. Support for Sequelize v4 is still experimental.
28676

287-
Additional note: If you need to access the sequelize instance, you can easily do that via `queryInterface.sequelize`. For example `queryInterface.sequelize.query('CREATE TABLE mytable();')`.
77+
Full support for Sequelize v4 is coming soon with [Sequelize CLI v4](https://github.com/sequelize/cli/issues/441)
28878

289-
## Documentation and FAQ
79+
## Documentation
29080

291-
More documentation around migrations [here](http://docs.sequelizejs.com/manual/tutorial/migrations.html). You can find FAQ section [here](https://github.com/sequelize/cli/blob/master/FAQ.md)
81+
- [Detailed CLI documentation](docs/README.md)
82+
- [Frequently Asked Questions](docs/FAQ.md)
83+
- [Query Interface API and Migrations](http://docs.sequelizejs.com/manual/tutorial/migrations.html)

FAQ.md docs/FAQ.md

File renamed without changes.

0 commit comments

Comments
 (0)