Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { inject } from '@adonisjs/fold'
import { BaseCommand, flags } from '@adonisjs/ace'
import { DatabaseContract } from '@ioc:Adonis/Lucid/Database'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { MigrationListNode } from '@ioc:Adonis/Lucid/Migrator'
/**
* The command is meant to migrate the database by execute migrations
* in `up` direction.
*/
@inject([null, 'Adonis/Lucid/Database'])
export default class Status extends BaseCommand {
public static commandName = 'migration:status'
public static description = 'Drop existing tables and re-run migrations from start'
@flags.string({ description: 'Define a custom database connection' })
public connection: string
/**
* This command loads the application, since we need the runtime
* to find the migration directories for a given connection
*/
public static settings = {
loadApp: true,
}
constructor (app: ApplicationContract, private _db: DatabaseContract) {
super(app)
}
/**
* Colorizes the status string
* Pre select migration directory. If this is defined, we will ignore the paths
* defined inside the config.
*/
@flags.string({ description: 'Pre-select a migration directory' })
public folder: string
/**
* Custom table name for creating a new table
*/
@flags.string({ description: 'Define the table name for creating a new table' })
public create: string
/**
* Custom table name for altering an existing table
*/
@flags.string({ description: 'Define the table name for altering an existing table' })
public table: string
/**
* This command loads the application, since we need the runtime
* to find the migration directories for a given connection
*/
public static settings = {
loadApp: true,
}
constructor (app: ApplicationContract, private _db: DatabaseContract) {
super(app)
}
/**
* Returns the directory for creating the migration file
import { inject } from '@adonisjs/fold'
import { DatabaseContract } from '@ioc:Adonis/Lucid/Database'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import MigrationsBase from './MigrationsBase'
/**
* The command is meant to migrate the database by execute migrations
* in `up` direction.
*/
@inject([null, 'Adonis/Lucid/Database'])
export default class Migrate extends MigrationsBase {
public static commandName = 'migration:rollback'
public static description = 'Rollback migrations to a given batch number'
@flags.string({ description: 'Define a custom database connection' })
public connection: string
@flags.boolean({ description: 'Print SQL queries, instead of running the migrations' })
public dryRun: boolean
@flags.number({
description: 'Define custom batch number for rollback. Use 0 to rollback to initial state',
})
public batch: number
/**
* This command loads the application, since we need the runtime
* to find the migration directories for a given connection
*/
public static settings = {
loadApp: true,
import { inject } from '@adonisjs/fold'
import { DatabaseContract } from '@ioc:Adonis/Lucid/Database'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import MigrationsBase from './MigrationsBase'
/**
* The command is meant to migrate the database by execute migrations
* in `up` direction.
*/
@inject([null, 'Adonis/Lucid/Database'])
export default class Migrate extends MigrationsBase {
public static commandName = 'migration:run'
public static description = 'Run pending migrations'
@flags.string({ description: 'Define a custom database connection' })
public connection: string
@flags.boolean({ description: 'Print SQL queries, instead of running the migrations' })
public dryRun: boolean
/**
* This command loads the application, since we need the runtime
* to find the migration directories for a given connection
*/
public static settings = {
loadApp: true,
}
constructor (app: ApplicationContract, private _db: DatabaseContract) {
super(app)
}