create-sip 1.4.2 → 1.4.3

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.
@@ -204,6 +204,41 @@ Generate a migration:
204
204
  node op make/migration thing
205
205
  ```
206
206
 
207
+ For example migration for employee table:
208
+
209
+ ```bash
210
+ node op make/migration employee
211
+ ```
212
+
213
+ ```javascript
214
+ import { DataTypes } from 'sequelize';
215
+
216
+ async function up({context: QueryInterface}) {
217
+ await QueryInterface.createTable('employees', {
218
+ id: {
219
+ allowNull: false,
220
+ autoIncrement: true,
221
+ primaryKey: true,
222
+ type: DataTypes.INTEGER
223
+ },
224
+ name: {
225
+ type: DataTypes.STRING
226
+ },
227
+ city: {
228
+ type: DataTypes.STRING
229
+ },
230
+ createdAt: { type: DataTypes.DATE },
231
+ updatedAt: { type: DataTypes.DATE }
232
+ });
233
+ }
234
+
235
+ async function down({context: QueryInterface}) {
236
+ await QueryInterface.dropTable('employees');
237
+ }
238
+
239
+ export { up, down }
240
+ ```
241
+
207
242
  Run all migration:
208
243
 
209
244
  ```bash
@@ -218,7 +253,7 @@ node op migration:run <migration_name>
218
253
  node op migrate <migration_name>
219
254
  ```
220
255
 
221
- Rollback a migration:
256
+ Rollback the last migration:
222
257
 
223
258
  ```bash
224
259
  node op migration:rollback
@@ -239,6 +274,8 @@ node op migration:reset
239
274
  node op migrate:reset
240
275
  ```
241
276
 
277
+ This command also undoes seeder operations.
278
+
242
279
  Reset the database and run all migrations:
243
280
 
244
281
  ```bash
@@ -254,6 +291,28 @@ Generate a seeder:
254
291
  node op make/seeder thing
255
292
  ```
256
293
 
294
+ Example seeder for employee table:
295
+
296
+ ```bash
297
+ node op make/seeder employee
298
+ ```
299
+
300
+ ```javascript
301
+
302
+ async function up({context: QueryInterface}) {
303
+ await QueryInterface.bulkInsert('employees', [
304
+ { id: 1, name: 'Joe Kitin' },
305
+ { id: 2, name: 'Peter Fall' }
306
+ ]);
307
+ }
308
+
309
+ async function down({context: QueryInterface}) {
310
+ await QueryInterface.bulkDelete('things', null, {});
311
+ }
312
+
313
+ export { up, down }
314
+ ````
315
+
257
316
  Run all seeders:
258
317
 
259
318
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sip",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "create-sip": "create-sip.js"