sqerge 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +69 -61
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -4,64 +4,72 @@ A forward only PostgreSQL migration tool. Uses [Postgres.js](https://github.com/
4
4
 
5
5
  ## Get Started
6
6
 
7
- 1. Install to devDependencies
8
- ```sh
9
- npm i sqerge -D
10
- ```
11
- 2. Choose a migration directory
12
- ```sh
13
- mkdir foo
14
- ```
15
- 3. Create some migration files
16
-
17
- The filename **prefix** represents the execution order, a unique integer followed by a hyphen. After the hyphen, it's all yours. Files not matching the prefix are ignored.
18
-
19
- ```sql
20
- -- file: ./foo/1-bar.sql
21
-
22
- CREATE TABLE person (
23
- "id" SERIAL PRIMARY KEY,
24
- "name" text NOT NULL
25
- );
26
- ```
27
-
28
- ```sql
29
- -- file: ./foo/2-biz.sql
30
-
31
- ALTER TABLE person
32
- ADD COLUMN "age" smallint;
33
- ```
34
-
35
- In addition to **.sql**, migration files can also end in **.js** or **.mjs** for ES Modules. JavaScript files must **default export a function**. The 1st argument is a [Postgres.js](https://github.com/porsager/postgres) instance.
36
-
37
- ```js
38
- // file: ./foo/3-baz.js
39
-
40
- module.exports = async (sql) => {
41
- await sql`
42
- INSERT INTO person
43
- ("name", "age")
44
- VALUES
45
- ('Luke Skywalker', '21');
46
- `;
47
- };
48
- ```
49
-
50
- 4. Execute migration
51
-
52
- Command:
53
-
54
- **Note:** Use [environment variables](https://www.postgresql.org/docs/current/libpq-envars.html) for your database connection. Supported environment variables are at the discretion of [Postgres.js](https://github.com/porsager/postgres).
55
-
56
- ```sh
57
- PGHOST=localhost PGPORT=5438 PGUSER=jonathan PGPASSWORD=iliketurtles PGDATABASE=dev npx sqerge ./foo
58
- ```
59
-
60
- Output:
61
-
62
- ```sh
63
- [sqerge] 3 file(s) found in '/Users/jonathan/Desktop/foo'
64
- [sqerge] file 1 (1-bar.sql): executed
65
- [sqerge] file 2 (2-biz.sql): executed
66
- [sqerge] file 3 (3-baz.js): executed
67
- ```
7
+ 1. Install NPM package
8
+
9
+ ```sh
10
+ npm i sqerge -D
11
+ ```
12
+
13
+ 2. Install Postgres.js (may install as peerDependency automatically on NPM v7+)
14
+
15
+ ```sh
16
+ npm i postgres
17
+ ```
18
+
19
+ 3. Choose a migration directory
20
+ ```sh
21
+ mkdir foo
22
+ ```
23
+ 4. Create some migration files
24
+
25
+ The filename **prefix** represents the execution order, a unique integer followed by a hyphen. After the hyphen, it's all yours. Files not matching the prefix are ignored.
26
+
27
+ ```sql
28
+ -- file: ./foo/1-bar.sql
29
+
30
+ CREATE TABLE person (
31
+ "id" SERIAL PRIMARY KEY,
32
+ "name" text NOT NULL
33
+ );
34
+ ```
35
+
36
+ ```sql
37
+ -- file: ./foo/2-biz.sql
38
+
39
+ ALTER TABLE person
40
+ ADD COLUMN "age" smallint;
41
+ ```
42
+
43
+ In addition to **.sql**, migration files can also end in **.js** or **.mjs** for ES Modules. JavaScript files must **default export a function**. The 1st argument is a [Postgres.js](https://github.com/porsager/postgres) instance.
44
+
45
+ ```js
46
+ // file: ./foo/3-baz.js
47
+
48
+ module.exports = async (sql) => {
49
+ await sql`
50
+ INSERT INTO person
51
+ ("name", "age")
52
+ VALUES
53
+ ('Luke Skywalker', '21');
54
+ `;
55
+ };
56
+ ```
57
+
58
+ 5. Execute migration
59
+
60
+ Command:
61
+
62
+ **Note:** Use [environment variables](https://www.postgresql.org/docs/current/libpq-envars.html) for your database connection. Supported environment variables are at the discretion of [Postgres.js](https://github.com/porsager/postgres).
63
+
64
+ ```sh
65
+ PGHOST=localhost PGPORT=5438 PGUSER=jonathan PGPASSWORD=iliketurtles PGDATABASE=dev npx sqerge ./foo
66
+ ```
67
+
68
+ Output:
69
+
70
+ ```sh
71
+ [sqerge] 3 file(s) found in '/Users/jonathan/Desktop/foo'
72
+ [sqerge] file 1 (1-bar.sql): executed
73
+ [sqerge] file 2 (2-biz.sql): executed
74
+ [sqerge] file 3 (3-baz.js): executed
75
+ ```
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "sqerge",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A forward only PostgreSQL migration tool.",
5
5
  "keywords": [
6
6
  "postgres",
7
7
  "postgresql",
8
8
  "sql",
9
9
  "migrate",
10
- "migration"
10
+ "migration",
11
+ "schema"
11
12
  ],
12
13
  "homepage": "https://github.com/eezing/sqerge#readme",
13
14
  "bugs": {