Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ v4 brings a new configuration structure and file.
This pairs with new features in CFMigrations to allow for multiple named migration managers and new seeding capabilities.
Migrations will still run in v4 using the old configuration structure and location, but it is highly recommended you upgrade.

You can create the new `.cfmigrations.json` config file by running `migrate init`.
You can create the new config file by running `migrate init`. The file can be named either `.migrations.json` or `.cfmigrations.json` (both are supported for backward compatibility).

The new config file format mirrors `CFMigrations`:

Expand Down Expand Up @@ -84,7 +84,9 @@ Make sure to append `@qb` to the end of any qb-supplied grammars, like `AutoDisc

## Setup

You need to create a `.cfmigrations.json` config file in your application root folder. You can do this easily by running `migrate init`:
You need to create a config file in your application root folder. You can do this easily by running `migrate init`.

The config file can be named either `.migrations.json` or `.cfmigrations.json` (both are supported for backward compatibility).

```json
{
Expand Down Expand Up @@ -211,7 +213,8 @@ You would update your `.gitignore` file to not ignore the `.env.example` file:

### `migrate init`

Creates the migration config file as `.cfmigrations.json`, if it doesn't already exist.
Creates the migration config file as `.migrations.json`, if it doesn't already exist.
(The older `.cfmigrations.json` name is also supported for backward compatibility.)

### `migrate install`

Expand Down
13 changes: 10 additions & 3 deletions commands/migrate/init.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ component {
function run( boolean open = false ) {
var directory = getCWD();

var configPath = "#directory#/.cfmigrations.json";
var configPath = "#directory#/.migrations.json";

// Check and see if a .cfmigrations.json file exists
// Check and see if a .migrations.json file exists
if ( fileExists( configPath ) ) {
print.yellowLine( ".migrations.json already exists." );
return;
}

// Check and see if a .cfmigrations.json file exists (for backward compatibility)
var oldConfigPath = "#directory#/.cfmigrations.json";
if ( fileExists( oldConfigPath ) ) {
print.yellowLine( ".cfmigrations.json already exists." );
return;
}
Expand All @@ -24,7 +31,7 @@ component {

file action="write" file="#configPath#" mode="777" output="#trim( configStub )#";

print.greenLine( "Created .cfmigrations config file." );
print.greenLine( "Created .migrations config file." );

// Open file?
if ( arguments.open ) {
Expand Down
17 changes: 15 additions & 2 deletions models/BaseMigrationCommand.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ component {

var directory = getCWD();

// Check and see if a .cfmigrations.json file exists
// Check and see if a .migrations.json file exists
if ( fileExists( "#directory#/.migrations.json" ) ) {
var cfmigrationsInfo = deserializeJSON( fileRead( "#directory#/.migrations.json" ) );
variables.systemSettings.expandDeepSystemSettings( cfmigrationsInfo );
cfmigrationsInfoType = "cfmigrations";
return cfmigrationsInfo;
}

// Check and see if a .cfmigrations.json file exists (for backward compatibility)
if ( fileExists( "#directory#/.cfmigrations.json" ) ) {
var cfmigrationsInfo = deserializeJSON( fileRead( "#directory#/.cfmigrations.json" ) );
variables.systemSettings.expandDeepSystemSettings( cfmigrationsInfo );
Expand Down Expand Up @@ -134,7 +142,12 @@ component {
private string function getCFMigrationsType() {
var directory = getCWD();

// Check and see if a .cfmigrations.json file exists
// Check and see if a .migrations.json file exists
if ( fileExists( "#directory#/.migrations.json" ) ) {
return "cfmigrations";
}

// Check and see if a .cfmigrations.json file exists (for backward compatibility)
if ( fileExists( "#directory#/.cfmigrations.json" ) ) {
return "cfmigrations";
}
Expand Down