diff --git a/README.md b/README.md index f83eb8e..3bf4ffd 100644 --- a/README.md +++ b/README.md @@ -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`: @@ -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 { @@ -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` diff --git a/commands/migrate/init.cfc b/commands/migrate/init.cfc index 4eb8ea1..cdb179b 100644 --- a/commands/migrate/init.cfc +++ b/commands/migrate/init.cfc @@ -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; } @@ -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 ) { diff --git a/models/BaseMigrationCommand.cfc b/models/BaseMigrationCommand.cfc index 1c52892..e717b7b 100644 --- a/models/BaseMigrationCommand.cfc +++ b/models/BaseMigrationCommand.cfc @@ -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 ); @@ -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"; }