@orchestr-sh/orchestr 1.5.11 → 1.6.0
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.
- package/README.md +199 -0
- package/dist/Console/Command.d.ts +59 -0
- package/dist/Console/Command.d.ts.map +1 -0
- package/dist/Console/Command.js +68 -0
- package/dist/Console/Command.js.map +1 -0
- package/dist/Console/Commands/MakeMigrationCommand.d.ts +15 -0
- package/dist/Console/Commands/MakeMigrationCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MakeMigrationCommand.js +41 -0
- package/dist/Console/Commands/MakeMigrationCommand.js.map +1 -0
- package/dist/Console/Commands/MakeSeederCommand.d.ts +23 -0
- package/dist/Console/Commands/MakeSeederCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MakeSeederCommand.js +109 -0
- package/dist/Console/Commands/MakeSeederCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateCommand.js +48 -0
- package/dist/Console/Commands/MigrateCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateFreshCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateFreshCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateFreshCommand.js +54 -0
- package/dist/Console/Commands/MigrateFreshCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateRefreshCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateRefreshCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateRefreshCommand.js +52 -0
- package/dist/Console/Commands/MigrateRefreshCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateResetCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateResetCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateResetCommand.js +46 -0
- package/dist/Console/Commands/MigrateResetCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateRollbackCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateRollbackCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateRollbackCommand.js +49 -0
- package/dist/Console/Commands/MigrateRollbackCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateStatusCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateStatusCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateStatusCommand.js +58 -0
- package/dist/Console/Commands/MigrateStatusCommand.js.map +1 -0
- package/dist/Console/Commands/SeedCommand.d.ts +15 -0
- package/dist/Console/Commands/SeedCommand.d.ts.map +1 -0
- package/dist/Console/Commands/SeedCommand.js +44 -0
- package/dist/Console/Commands/SeedCommand.js.map +1 -0
- package/dist/Console/ConsoleKernel.d.ts +45 -0
- package/dist/Console/ConsoleKernel.d.ts.map +1 -0
- package/dist/Console/ConsoleKernel.js +109 -0
- package/dist/Console/ConsoleKernel.js.map +1 -0
- package/dist/Console/orchestr.d.ts +8 -0
- package/dist/Console/orchestr.d.ts.map +1 -0
- package/dist/Console/orchestr.js +45 -0
- package/dist/Console/orchestr.js.map +1 -0
- package/dist/Database/Migrations/Blueprint.d.ts +166 -0
- package/dist/Database/Migrations/Blueprint.d.ts.map +1 -0
- package/dist/Database/Migrations/Blueprint.js +318 -0
- package/dist/Database/Migrations/Blueprint.js.map +1 -0
- package/dist/Database/Migrations/ColumnDefinition.d.ts +62 -0
- package/dist/Database/Migrations/ColumnDefinition.d.ts.map +1 -0
- package/dist/Database/Migrations/ColumnDefinition.js +95 -0
- package/dist/Database/Migrations/ColumnDefinition.js.map +1 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.d.ts +32 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.d.ts.map +1 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.js +50 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.js.map +1 -0
- package/dist/Database/Migrations/Migration.d.ts +17 -0
- package/dist/Database/Migrations/Migration.d.ts.map +1 -0
- package/dist/Database/Migrations/Migration.js +12 -0
- package/dist/Database/Migrations/Migration.js.map +1 -0
- package/dist/Database/Migrations/MigrationCreator.d.ts +42 -0
- package/dist/Database/Migrations/MigrationCreator.d.ts.map +1 -0
- package/dist/Database/Migrations/MigrationCreator.js +184 -0
- package/dist/Database/Migrations/MigrationCreator.js.map +1 -0
- package/dist/Database/Migrations/MigrationRepository.d.ts +65 -0
- package/dist/Database/Migrations/MigrationRepository.d.ts.map +1 -0
- package/dist/Database/Migrations/MigrationRepository.js +135 -0
- package/dist/Database/Migrations/MigrationRepository.js.map +1 -0
- package/dist/Database/Migrations/Migrator.d.ts +84 -0
- package/dist/Database/Migrations/Migrator.d.ts.map +1 -0
- package/dist/Database/Migrations/Migrator.js +239 -0
- package/dist/Database/Migrations/Migrator.js.map +1 -0
- package/dist/Database/Migrations/SchemaBuilder.d.ts +136 -0
- package/dist/Database/Migrations/SchemaBuilder.d.ts.map +1 -0
- package/dist/Database/Migrations/SchemaBuilder.js +515 -0
- package/dist/Database/Migrations/SchemaBuilder.js.map +1 -0
- package/dist/Database/Seeders/Seeder.d.ts +29 -0
- package/dist/Database/Seeders/Seeder.d.ts.map +1 -0
- package/dist/Database/Seeders/Seeder.js +41 -0
- package/dist/Database/Seeders/Seeder.js.map +1 -0
- package/dist/Database/Seeders/SeederRunner.d.ts +41 -0
- package/dist/Database/Seeders/SeederRunner.d.ts.map +1 -0
- package/dist/Database/Seeders/SeederRunner.js +134 -0
- package/dist/Database/Seeders/SeederRunner.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -218,6 +218,140 @@ const allPosts = await user.posts;
|
|
|
218
218
|
|
|
219
219
|
Without `@DynamicRelation`, you must always call the method: `user.posts().get()`.
|
|
220
220
|
|
|
221
|
+
## Migrations
|
|
222
|
+
|
|
223
|
+
Laravel-style migrations with a fluent Schema builder.
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Create a migration
|
|
227
|
+
orchestr make:migration create_users_table --create=users
|
|
228
|
+
|
|
229
|
+
# Run migrations
|
|
230
|
+
orchestr migrate
|
|
231
|
+
|
|
232
|
+
# Rollback last batch
|
|
233
|
+
orchestr migrate:rollback
|
|
234
|
+
|
|
235
|
+
# Rollback all migrations
|
|
236
|
+
orchestr migrate:reset
|
|
237
|
+
|
|
238
|
+
# Drop all tables and re-run migrations
|
|
239
|
+
orchestr migrate:fresh
|
|
240
|
+
|
|
241
|
+
# Rollback and re-run all migrations
|
|
242
|
+
orchestr migrate:refresh
|
|
243
|
+
|
|
244
|
+
# Check migration status
|
|
245
|
+
orchestr migrate:status
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Creating Tables
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { Migration, Schema } from '@orchestr-sh/orchestr';
|
|
252
|
+
|
|
253
|
+
export default class extends Migration {
|
|
254
|
+
async up(schema: Schema): Promise<void> {
|
|
255
|
+
await schema.create('users', (table) => {
|
|
256
|
+
table.id();
|
|
257
|
+
table.string('name');
|
|
258
|
+
table.string('email').unique();
|
|
259
|
+
table.string('password');
|
|
260
|
+
table.rememberToken();
|
|
261
|
+
table.timestamps();
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async down(schema: Schema): Promise<void> {
|
|
266
|
+
await schema.dropIfExists('users');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Column Types
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
table.id() // Auto-incrementing big integer
|
|
275
|
+
table.string('name', 255) // VARCHAR
|
|
276
|
+
table.text('bio') // TEXT
|
|
277
|
+
table.integer('votes') // INTEGER
|
|
278
|
+
table.bigInteger('amount') // BIGINT
|
|
279
|
+
table.decimal('price', 8, 2) // DECIMAL
|
|
280
|
+
table.boolean('active') // BOOLEAN
|
|
281
|
+
table.date('birth_date') // DATE
|
|
282
|
+
table.datetime('published_at') // DATETIME
|
|
283
|
+
table.timestamp('created_at') // TIMESTAMP
|
|
284
|
+
table.timestamps() // created_at & updated_at
|
|
285
|
+
table.json('metadata') // JSON
|
|
286
|
+
table.uuid('identifier') // UUID
|
|
287
|
+
table.enum('status', ['draft', 'published'])
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Column Modifiers
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
table.string('email').nullable()
|
|
294
|
+
table.string('email').unique()
|
|
295
|
+
table.string('email').default('guest@example.com')
|
|
296
|
+
table.integer('votes').unsigned()
|
|
297
|
+
table.string('email').index()
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Foreign Keys
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
table.bigInteger('user_id').unsigned();
|
|
304
|
+
table.foreign('user_id').references('id').on('users').onDelete('cascade');
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Seeders
|
|
308
|
+
|
|
309
|
+
Populate your database with test or initial data.
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
# Create a seeder
|
|
313
|
+
orchestr make:seeder UserSeeder
|
|
314
|
+
|
|
315
|
+
# Run all seeders (runs DatabaseSeeder)
|
|
316
|
+
orchestr db:seed
|
|
317
|
+
|
|
318
|
+
# Run a specific seeder
|
|
319
|
+
orchestr db:seed --class=UserSeeder
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Creating Seeders
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
import { Seeder } from '@orchestr-sh/orchestr';
|
|
326
|
+
|
|
327
|
+
export default class UserSeeder extends Seeder {
|
|
328
|
+
async run(): Promise<void> {
|
|
329
|
+
await this.connection?.table('users').insert([
|
|
330
|
+
{ name: 'John Doe', email: 'john@example.com' },
|
|
331
|
+
{ name: 'Jane Smith', email: 'jane@example.com' },
|
|
332
|
+
]);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### DatabaseSeeder Pattern
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
import { Seeder } from '@orchestr-sh/orchestr';
|
|
341
|
+
import UserSeeder from './UserSeeder';
|
|
342
|
+
import PostSeeder from './PostSeeder';
|
|
343
|
+
|
|
344
|
+
export default class DatabaseSeeder extends Seeder {
|
|
345
|
+
async run(): Promise<void> {
|
|
346
|
+
await this.call(UserSeeder);
|
|
347
|
+
await this.call(PostSeeder);
|
|
348
|
+
|
|
349
|
+
// Or call multiple seeders at once
|
|
350
|
+
await this.callMany([UserSeeder, PostSeeder]);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
221
355
|
## Controllers
|
|
222
356
|
|
|
223
357
|
```typescript
|
|
@@ -365,6 +499,49 @@ user.toObject() // Convert to plain object
|
|
|
365
499
|
.max(column)
|
|
366
500
|
```
|
|
367
501
|
|
|
502
|
+
### Schema Methods
|
|
503
|
+
|
|
504
|
+
```typescript
|
|
505
|
+
schema.create(table, callback) // Create new table
|
|
506
|
+
schema.table(table, callback) // Modify existing table
|
|
507
|
+
schema.drop(table) // Drop table
|
|
508
|
+
schema.dropIfExists(table) // Drop table if exists
|
|
509
|
+
schema.rename(from, to) // Rename table
|
|
510
|
+
schema.hasTable(table) // Check if table exists
|
|
511
|
+
schema.hasColumn(table, column) // Check if column exists
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### Blueprint Column Types
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
table.id() // Auto-increment big integer
|
|
518
|
+
table.increments(column) // Auto-increment integer
|
|
519
|
+
table.bigIncrements(column) // Auto-increment big integer
|
|
520
|
+
table.string(column, length) // VARCHAR
|
|
521
|
+
table.text(column) // TEXT
|
|
522
|
+
table.mediumText(column) // MEDIUMTEXT
|
|
523
|
+
table.longText(column) // LONGTEXT
|
|
524
|
+
table.integer(column) // INTEGER
|
|
525
|
+
table.bigInteger(column) // BIGINT
|
|
526
|
+
table.smallInteger(column) // SMALLINT
|
|
527
|
+
table.tinyInteger(column) // TINYINT
|
|
528
|
+
table.decimal(column, precision, scale)
|
|
529
|
+
table.float(column, precision, scale)
|
|
530
|
+
table.double(column, precision, scale)
|
|
531
|
+
table.boolean(column) // BOOLEAN
|
|
532
|
+
table.date(column) // DATE
|
|
533
|
+
table.datetime(column, precision) // DATETIME
|
|
534
|
+
table.timestamp(column, precision) // TIMESTAMP
|
|
535
|
+
table.timestamps(precision) // created_at & updated_at
|
|
536
|
+
table.json(column) // JSON
|
|
537
|
+
table.jsonb(column) // JSONB
|
|
538
|
+
table.uuid(column) // UUID
|
|
539
|
+
table.enum(column, values) // ENUM
|
|
540
|
+
table.binary(column) // BINARY
|
|
541
|
+
table.rememberToken() // remember_token VARCHAR(100)
|
|
542
|
+
table.softDeletes(column) // deleted_at timestamp
|
|
543
|
+
```
|
|
544
|
+
|
|
368
545
|
### Relationship Methods
|
|
369
546
|
|
|
370
547
|
```typescript
|
|
@@ -400,6 +577,26 @@ user.toObject() // Convert to plain object
|
|
|
400
577
|
- `MorphToMany` - Polymorphic many-to-many
|
|
401
578
|
- `MorphedByMany` - Inverse of MorphToMany
|
|
402
579
|
|
|
580
|
+
### CLI Commands
|
|
581
|
+
|
|
582
|
+
```bash
|
|
583
|
+
# Migrations
|
|
584
|
+
orchestr make:migration <name> # Create migration
|
|
585
|
+
orchestr make:migration <name> --create=<table> # Create table migration
|
|
586
|
+
orchestr make:migration <name> --table=<table> # Update table migration
|
|
587
|
+
orchestr migrate # Run migrations
|
|
588
|
+
orchestr migrate:rollback # Rollback last batch
|
|
589
|
+
orchestr migrate:reset # Rollback all migrations
|
|
590
|
+
orchestr migrate:refresh # Reset and re-run migrations
|
|
591
|
+
orchestr migrate:fresh # Drop all tables and migrate
|
|
592
|
+
orchestr migrate:status # Show migration status
|
|
593
|
+
|
|
594
|
+
# Seeders
|
|
595
|
+
orchestr make:seeder <name> # Create seeder
|
|
596
|
+
orchestr db:seed # Run DatabaseSeeder
|
|
597
|
+
orchestr db:seed --class=<name> # Run specific seeder
|
|
598
|
+
```
|
|
599
|
+
|
|
403
600
|
## Features
|
|
404
601
|
|
|
405
602
|
- ✅ Service Container & Dependency Injection
|
|
@@ -411,6 +608,8 @@ user.toObject() // Convert to plain object
|
|
|
411
608
|
- ✅ Ensemble ORM (ActiveRecord)
|
|
412
609
|
- ✅ Relationships (Standard + Polymorphic)
|
|
413
610
|
- ✅ Eager/Lazy Loading
|
|
611
|
+
- ✅ Migrations with Schema Builder
|
|
612
|
+
- ✅ Database Seeders
|
|
414
613
|
- ✅ Soft Deletes
|
|
415
614
|
- ✅ Attribute Casting
|
|
416
615
|
- ✅ Timestamps
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command
|
|
3
|
+
*
|
|
4
|
+
* Base class for all console commands
|
|
5
|
+
*/
|
|
6
|
+
export interface CommandOptions {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class Command {
|
|
10
|
+
/**
|
|
11
|
+
* The name of the command
|
|
12
|
+
*/
|
|
13
|
+
abstract signature: string;
|
|
14
|
+
/**
|
|
15
|
+
* The description of the command
|
|
16
|
+
*/
|
|
17
|
+
abstract description: string;
|
|
18
|
+
/**
|
|
19
|
+
* Execute the command
|
|
20
|
+
*/
|
|
21
|
+
abstract handle(args: string[], options: CommandOptions): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Write a message to the console
|
|
24
|
+
*/
|
|
25
|
+
protected info(message: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Write an error message to the console
|
|
28
|
+
*/
|
|
29
|
+
protected error(message: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Write a warning message to the console
|
|
32
|
+
*/
|
|
33
|
+
protected warn(message: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Write a comment message to the console
|
|
36
|
+
*/
|
|
37
|
+
protected comment(message: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Write a question message to the console
|
|
40
|
+
*/
|
|
41
|
+
protected question(message: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Write a line to the console
|
|
44
|
+
*/
|
|
45
|
+
protected line(message?: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Write a newline to the console
|
|
48
|
+
*/
|
|
49
|
+
protected newLine(count?: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Write a table to the console
|
|
52
|
+
*/
|
|
53
|
+
protected table(headers: string[], rows: any[][]): void;
|
|
54
|
+
/**
|
|
55
|
+
* Get the command name from the signature
|
|
56
|
+
*/
|
|
57
|
+
getName(): string;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=Command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../src/Console/Command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,8BAAsB,OAAO;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAEvE;;OAEG;IACH,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAItC;;OAEG;IACH,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIzC;;OAEG;IACH,SAAS,CAAC,IAAI,CAAC,OAAO,GAAE,MAAW,GAAG,IAAI;IAI1C;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,KAAK,GAAE,MAAU,GAAG,IAAI;IAM1C;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,IAAI;IAIvD;;OAEG;IACH,OAAO,IAAI,MAAM;CAGlB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Command
|
|
4
|
+
*
|
|
5
|
+
* Base class for all console commands
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Command = void 0;
|
|
9
|
+
class Command {
|
|
10
|
+
/**
|
|
11
|
+
* Write a message to the console
|
|
12
|
+
*/
|
|
13
|
+
info(message) {
|
|
14
|
+
console.log(`\x1b[32m${message}\x1b[0m`);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Write an error message to the console
|
|
18
|
+
*/
|
|
19
|
+
error(message) {
|
|
20
|
+
console.error(`\x1b[31m${message}\x1b[0m`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Write a warning message to the console
|
|
24
|
+
*/
|
|
25
|
+
warn(message) {
|
|
26
|
+
console.warn(`\x1b[33m${message}\x1b[0m`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Write a comment message to the console
|
|
30
|
+
*/
|
|
31
|
+
comment(message) {
|
|
32
|
+
console.log(`\x1b[90m${message}\x1b[0m`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Write a question message to the console
|
|
36
|
+
*/
|
|
37
|
+
question(message) {
|
|
38
|
+
console.log(`\x1b[36m${message}\x1b[0m`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Write a line to the console
|
|
42
|
+
*/
|
|
43
|
+
line(message = '') {
|
|
44
|
+
console.log(message);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Write a newline to the console
|
|
48
|
+
*/
|
|
49
|
+
newLine(count = 1) {
|
|
50
|
+
for (let i = 0; i < count; i++) {
|
|
51
|
+
console.log();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Write a table to the console
|
|
56
|
+
*/
|
|
57
|
+
table(headers, rows) {
|
|
58
|
+
console.table(rows, headers);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the command name from the signature
|
|
62
|
+
*/
|
|
63
|
+
getName() {
|
|
64
|
+
return this.signature.split(' ')[0];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Command = Command;
|
|
68
|
+
//# sourceMappingURL=Command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.js","sourceRoot":"","sources":["../../src/Console/Command.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAMH,MAAsB,OAAO;IAgB3B;;OAEG;IACO,IAAI,CAAC,OAAe;QAC5B,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,OAAe;QAC7B,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,IAAI,CAAC,OAAe;QAC5B,OAAO,CAAC,IAAI,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACO,OAAO,CAAC,OAAe;QAC/B,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAe;QAChC,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACO,IAAI,CAAC,UAAkB,EAAE;QACjC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED;;OAEG;IACO,OAAO,CAAC,QAAgB,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,OAAiB,EAAE,IAAa;QAC9C,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;CACF;AAhFD,0BAgFC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MakeMigrationCommand
|
|
3
|
+
*
|
|
4
|
+
* Create a new migration file
|
|
5
|
+
*/
|
|
6
|
+
import { Command, CommandOptions } from '../Command';
|
|
7
|
+
import { Application } from '../../Foundation/Application';
|
|
8
|
+
export declare class MakeMigrationCommand extends Command {
|
|
9
|
+
protected app: Application;
|
|
10
|
+
signature: string;
|
|
11
|
+
description: string;
|
|
12
|
+
constructor(app: Application);
|
|
13
|
+
handle(args: string[], options: CommandOptions): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MakeMigrationCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MakeMigrationCommand.d.ts","sourceRoot":"","sources":["../../../src/Console/Commands/MakeMigrationCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,qBAAa,oBAAqB,SAAQ,OAAO;IAInC,SAAS,CAAC,GAAG,EAAE,WAAW;IAHtC,SAAS,SAA2B;IACpC,WAAW,SAAiC;gBAEtB,GAAG,EAAE,WAAW;IAIhC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAwBrE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MakeMigrationCommand
|
|
4
|
+
*
|
|
5
|
+
* Create a new migration file
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.MakeMigrationCommand = void 0;
|
|
9
|
+
const Command_1 = require("../Command");
|
|
10
|
+
const MigrationCreator_1 = require("../../Database/Migrations/MigrationCreator");
|
|
11
|
+
class MakeMigrationCommand extends Command_1.Command {
|
|
12
|
+
app;
|
|
13
|
+
signature = 'make:migration <name>';
|
|
14
|
+
description = 'Create a new migration file';
|
|
15
|
+
constructor(app) {
|
|
16
|
+
super();
|
|
17
|
+
this.app = app;
|
|
18
|
+
}
|
|
19
|
+
async handle(args, options) {
|
|
20
|
+
const name = args[0];
|
|
21
|
+
if (!name) {
|
|
22
|
+
this.error('Migration name is required.');
|
|
23
|
+
this.line('Usage: make:migration <name>');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const migrationPath = options.path || './database/migrations';
|
|
27
|
+
const table = options.table;
|
|
28
|
+
const create = options.create === true;
|
|
29
|
+
const creator = new MigrationCreator_1.MigrationCreator();
|
|
30
|
+
try {
|
|
31
|
+
const filePath = await creator.create(name, migrationPath, table, create);
|
|
32
|
+
this.info(`Migration created successfully: ${filePath}`);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
this.error(`Failed to create migration: ${error.message}`);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.MakeMigrationCommand = MakeMigrationCommand;
|
|
41
|
+
//# sourceMappingURL=MakeMigrationCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MakeMigrationCommand.js","sourceRoot":"","sources":["../../../src/Console/Commands/MakeMigrationCommand.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,wCAAqD;AAErD,iFAA8E;AAE9E,MAAa,oBAAqB,SAAQ,iBAAO;IAIzB;IAHtB,SAAS,GAAG,uBAAuB,CAAC;IACpC,WAAW,GAAG,6BAA6B,CAAC;IAE5C,YAAsB,GAAgB;QACpC,KAAK,EAAE,CAAC;QADY,QAAG,GAAH,GAAG,CAAa;IAEtC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAc,EAAE,OAAuB;QAClD,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAErB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,IAAI,uBAAuB,CAAC;QAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,KAA2B,CAAC;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC;QAEvC,MAAM,OAAO,GAAG,IAAI,mCAAgB,EAAE,CAAC;QAEvC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YAE1E,IAAI,CAAC,IAAI,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,+BAAgC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAhCD,oDAgCC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MakeSeederCommand
|
|
3
|
+
*
|
|
4
|
+
* Create a new seeder class
|
|
5
|
+
*/
|
|
6
|
+
import { Command, CommandOptions } from '../Command';
|
|
7
|
+
import { Application } from '../../Foundation/Application';
|
|
8
|
+
export declare class MakeSeederCommand extends Command {
|
|
9
|
+
protected app: Application;
|
|
10
|
+
signature: string;
|
|
11
|
+
description: string;
|
|
12
|
+
constructor(app: Application);
|
|
13
|
+
handle(args: string[], options: CommandOptions): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new seeder file
|
|
16
|
+
*/
|
|
17
|
+
protected createSeeder(name: string, seederPath: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the seeder stub
|
|
20
|
+
*/
|
|
21
|
+
protected getStub(name: string): string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=MakeSeederCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MakeSeederCommand.d.ts","sourceRoot":"","sources":["../../../src/Console/Commands/MakeSeederCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,qBAAa,iBAAkB,SAAQ,OAAO;IAIhC,SAAS,CAAC,GAAG,EAAE,WAAW;IAHtC,SAAS,SAAwB;IACjC,WAAW,SAA+B;gBAEpB,GAAG,EAAE,WAAW;IAIhC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpE;;OAEG;cACa,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB/E;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAiBxC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MakeSeederCommand
|
|
4
|
+
*
|
|
5
|
+
* Create a new seeder class
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.MakeSeederCommand = void 0;
|
|
42
|
+
const Command_1 = require("../Command");
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
class MakeSeederCommand extends Command_1.Command {
|
|
46
|
+
app;
|
|
47
|
+
signature = 'make:seeder <name>';
|
|
48
|
+
description = 'Create a new seeder class';
|
|
49
|
+
constructor(app) {
|
|
50
|
+
super();
|
|
51
|
+
this.app = app;
|
|
52
|
+
}
|
|
53
|
+
async handle(args, options) {
|
|
54
|
+
const name = args[0];
|
|
55
|
+
if (!name) {
|
|
56
|
+
this.error('Seeder name is required.');
|
|
57
|
+
this.line('Usage: make:seeder <name>');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const seederPath = options.path || './database/seeders';
|
|
61
|
+
try {
|
|
62
|
+
const filePath = await this.createSeeder(name, seederPath);
|
|
63
|
+
this.info(`Seeder created successfully: ${filePath}`);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
this.error(`Failed to create seeder: ${error.message}`);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a new seeder file
|
|
72
|
+
*/
|
|
73
|
+
async createSeeder(name, seederPath) {
|
|
74
|
+
// Ensure directory exists
|
|
75
|
+
if (!fs.existsSync(seederPath)) {
|
|
76
|
+
fs.mkdirSync(seederPath, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
const fileName = `${name}.ts`;
|
|
79
|
+
const filePath = path.join(seederPath, fileName);
|
|
80
|
+
if (fs.existsSync(filePath)) {
|
|
81
|
+
throw new Error(`Seeder already exists: ${filePath}`);
|
|
82
|
+
}
|
|
83
|
+
const stub = this.getStub(name);
|
|
84
|
+
fs.writeFileSync(filePath, stub);
|
|
85
|
+
return filePath;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the seeder stub
|
|
89
|
+
*/
|
|
90
|
+
getStub(name) {
|
|
91
|
+
return `import { Seeder } from '@orchestr-sh/orchestr';
|
|
92
|
+
|
|
93
|
+
export default class ${name} extends Seeder {
|
|
94
|
+
/**
|
|
95
|
+
* Run the database seeds
|
|
96
|
+
*/
|
|
97
|
+
async run(): Promise<void> {
|
|
98
|
+
// Example: Insert data into database
|
|
99
|
+
// await this.connection?.table('users').insert({
|
|
100
|
+
// name: 'John Doe',
|
|
101
|
+
// email: 'john@example.com',
|
|
102
|
+
// });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.MakeSeederCommand = MakeSeederCommand;
|
|
109
|
+
//# sourceMappingURL=MakeSeederCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MakeSeederCommand.js","sourceRoot":"","sources":["../../../src/Console/Commands/MakeSeederCommand.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAqD;AAErD,uCAAyB;AACzB,2CAA6B;AAE7B,MAAa,iBAAkB,SAAQ,iBAAO;IAItB;IAHtB,SAAS,GAAG,oBAAoB,CAAC;IACjC,WAAW,GAAG,2BAA2B,CAAC;IAE1C,YAAsB,GAAgB;QACpC,KAAK,EAAE,CAAC;QADY,QAAG,GAAH,GAAG,CAAa;IAEtC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAc,EAAE,OAAuB;QAClD,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAErB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YACvC,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,oBAAoB,CAAC;QAExD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAE3D,IAAI,CAAC,IAAI,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,4BAA6B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACnE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,YAAY,CAAC,IAAY,EAAE,UAAkB;QAC3D,0BAA0B;QAC1B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,QAAQ,GAAG,GAAG,IAAI,KAAK,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEjD,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACO,OAAO,CAAC,IAAY;QAC5B,OAAO;;uBAEY,IAAI;;;;;;;;;;;;CAY1B,CAAC;IACA,CAAC;CACF;AAvED,8CAuEC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MigrateCommand
|
|
3
|
+
*
|
|
4
|
+
* Run the database migrations
|
|
5
|
+
*/
|
|
6
|
+
import { Command, CommandOptions } from '../Command';
|
|
7
|
+
import { Application } from '../../Foundation/Application';
|
|
8
|
+
export declare class MigrateCommand extends Command {
|
|
9
|
+
protected app: Application;
|
|
10
|
+
signature: string;
|
|
11
|
+
description: string;
|
|
12
|
+
constructor(app: Application);
|
|
13
|
+
handle(args: string[], options: CommandOptions): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MigrateCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../src/Console/Commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,qBAAa,cAAe,SAAQ,OAAO;IAI7B,SAAS,CAAC,GAAG,EAAE,WAAW;IAHtC,SAAS,SAAa;IACtB,WAAW,SAAiC;gBAEtB,GAAG,EAAE,WAAW;IAIhC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAgCrE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MigrateCommand
|
|
4
|
+
*
|
|
5
|
+
* Run the database migrations
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.MigrateCommand = void 0;
|
|
9
|
+
const Command_1 = require("../Command");
|
|
10
|
+
const Migrator_1 = require("../../Database/Migrations/Migrator");
|
|
11
|
+
class MigrateCommand extends Command_1.Command {
|
|
12
|
+
app;
|
|
13
|
+
signature = 'migrate';
|
|
14
|
+
description = 'Run the database migrations';
|
|
15
|
+
constructor(app) {
|
|
16
|
+
super();
|
|
17
|
+
this.app = app;
|
|
18
|
+
}
|
|
19
|
+
async handle(args, options) {
|
|
20
|
+
const db = this.app.make('db');
|
|
21
|
+
const connection = db.connection();
|
|
22
|
+
const migrationPath = options.path || './database/migrations';
|
|
23
|
+
const paths = Array.isArray(migrationPath) ? migrationPath : [migrationPath];
|
|
24
|
+
const migrator = new Migrator_1.Migrator(connection, paths);
|
|
25
|
+
this.info('Running migrations...');
|
|
26
|
+
this.newLine();
|
|
27
|
+
try {
|
|
28
|
+
const ran = await migrator.run({
|
|
29
|
+
pretend: options.pretend === true,
|
|
30
|
+
});
|
|
31
|
+
if (ran.length === 0) {
|
|
32
|
+
this.comment('Nothing to migrate.');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
ran.forEach((migration) => {
|
|
36
|
+
this.info(`Migrated: ${migration}`);
|
|
37
|
+
});
|
|
38
|
+
this.newLine();
|
|
39
|
+
this.info(`Migration completed successfully.`);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
this.error(`Migration failed: ${error.message}`);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.MigrateCommand = MigrateCommand;
|
|
48
|
+
//# sourceMappingURL=MigrateCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrateCommand.js","sourceRoot":"","sources":["../../../src/Console/Commands/MigrateCommand.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,wCAAqD;AAErD,iEAA8D;AAE9D,MAAa,cAAe,SAAQ,iBAAO;IAInB;IAHtB,SAAS,GAAG,SAAS,CAAC;IACtB,WAAW,GAAG,6BAA6B,CAAC;IAE5C,YAAsB,GAAgB;QACpC,KAAK,EAAE,CAAC;QADY,QAAG,GAAH,GAAG,CAAa;IAEtC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAc,EAAE,OAAuB;QAClD,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAQ,CAAC;QACtC,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC;QACnC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,IAAI,uBAAuB,CAAC;QAC9D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;QAE7E,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAEjD,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC;gBAC7B,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,IAAI;aAClC,CAAC,CAAC;YAEH,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrB,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;gBACpC,OAAO;YACT,CAAC;YAED,GAAG,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACxB,IAAI,CAAC,IAAI,CAAC,aAAa,SAAS,EAAE,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,qBAAsB,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAxCD,wCAwCC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MigrateFreshCommand
|
|
3
|
+
*
|
|
4
|
+
* Drop all tables and re-run all migrations
|
|
5
|
+
*/
|
|
6
|
+
import { Command, CommandOptions } from '../Command';
|
|
7
|
+
import { Application } from '../../Foundation/Application';
|
|
8
|
+
export declare class MigrateFreshCommand extends Command {
|
|
9
|
+
protected app: Application;
|
|
10
|
+
signature: string;
|
|
11
|
+
description: string;
|
|
12
|
+
constructor(app: Application);
|
|
13
|
+
handle(args: string[], options: CommandOptions): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MigrateFreshCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrateFreshCommand.d.ts","sourceRoot":"","sources":["../../../src/Console/Commands/MigrateFreshCommand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAI3D,qBAAa,mBAAoB,SAAQ,OAAO;IAIlC,SAAS,CAAC,GAAG,EAAE,WAAW;IAHtC,SAAS,SAAmB;IAC5B,WAAW,SAA+C;gBAEpC,GAAG,EAAE,WAAW;IAIhC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAsCrE"}
|