The changes of each release that this documentation covers, newest first. The source is CHANGELOG.md of the repository.
Unreleased
Added
- Added tests for the code coverage of the small classes:
ListTablesDb,Helper(the choice of a migrations folder, a parent folder that is not writable),Camelize,FieldDefinition(the pairing of a renamed column),InvalidArgumentExceptionandColor, and the faketests/Fakes/Utils/FakeStdinWrapperforphp://stdin(#299) - Added tests for the code coverage of the CLI command: the
clean,export,listandmigrate-filesactions, the default migrations folders, a relative migrations folder of the config, and the search forconfig/config.php(#301) - Added tests for the code coverage of the adapters and
Generate: the SQLite no-op methods (foreign keys, the primary key),dropIndex(),getCurrentSchema()and the defaults; the PostgreSQL scale,DEFAULT NULLand a reference with no name; the MySQLfirstcolumn position and a reference with no name;Generate::createDumpFiles()with a connection andgetCode()beforecreateEntity()(#303) - Added tests for the code coverage of
Migrations: the errors of the actions (no folder, no config, no adapter),exportwith a table name and with a file that has no morph,generateandrunwith a table prefix or names, the version column oflist, a rollback over a version that did not run, the paths and the errors of the file log, andimport-logwith a version that does not fit (#313) - Added tests for the code coverage of
Mvc\Model\Migration: the errors ofmorphTable()(a failed add, modify or drop of a column, an index, a foreign key or the primary key, on MySQL and PostgreSQL), the changes of an index, a primary key and a foreign key, an old-format reference,--skip-foreign-checks, the hooksafterUp(),afterDown()andafterCreateTable(), and the errors of the class loader (#317) - Added tests for the escaped Infection mutants of the small classes:
addMinor()and the stamp ofIncrementalItem, the compare of an incremental and a timestamped version, the timestamped version pattern, the folder question ofHelper(the new faketests/Fakes/Utils/FakeStdoutFilterforSTDOUT),Camelizewith a dash between delimiters and with a multibyte letter, the output ofProfilerandDbProfilerListener, andListTablesDbon PostgreSQL (#354) - Added tests for the escaped Infection mutants of the DB core classes: the default ports and the port of the config, an adapter name in upper case, the logger of each query and the escape of a quote in an identifier of
Connection; the casts ofColumn; the flags, the position and a size or scale of 0 ofPhalconColumnBridge; the compare of the auto increment and of anulldefault ofFieldDefinition; the actions ofReference(#356) - Added tests for the escaped Infection mutants of the adapters: the exact SQL of a new table (the keys, the foreign keys, the table options, a type with no DDL name, the defaults of a function), the foreign key checks of
dropTables()andemptyTables()(MySQL, SQLite), the typed defaults of the numeric columns and the statistics cache (MySQL), the columns with a comment,modifyColumn()and the tables of another schema (PostgreSQL), the declared types, the index types and two foreign keys (SQLite) (#358) - Added tests for the escaped Infection mutants of
GenerateandMvc\Model\Migration: the checks beforecreateEntity(), the defaults of theadd*()methods and ofcreateDumpFiles(), the order of the parts of the morph, the type and the primary flag of each adapter, the text of a foreign key; the profiler ofsetup(),isSameTable()on PostgreSQL,migrate()to the same version, the batches ofbatchInsert(), the collect mode ofgetTableDefinition(), the namespace, an old format foreign key on a table that exists, the changes of a foreign key and of a primary key (#360) - Added tests for the escaped Infection mutants of
Migrations: the exact output oflistAll(),generate(),clean(),run()andimportLog(), the log of each call (also after another call in one process), the file log (the folder, the reset, the order),getCurrentVersion(),removeCurrentVersion(),createLogTable(), the rollback ofimportLog(), the export with a separator at the end of the folder and with the adapter of its config, the order of the tables of a version, the compare ofgenerate()with the newest version, and the checks of the versions with one old order number (#363) - Added tests for the escaped Infection mutants of the console: the whole help text of the
migrationandmigrate-filescommands (the filestests/_data/console/*.txt), the text of each message style ofColorand its terminal check, the messages ofmigrate-files, the options that the command gives togenerate,run,listandclean, the config inapp/config/and in aninifile, aJSONextension, and the version ofOptionStack(the type, an existing version, the newest version of all the folders) (#366) - Added
pgsql(the PDO name) as an alias ofpostgresqlfor theadapterof the config.postgresqlstays the documented name (#326) - Added the round-trip contract tests of the morph on MySQL, PostgreSQL and SQLite: a second morph with the same definition sends no change, the file of
generatesends no change, and a rename of a column keeps the data. Each failure of today is a skipped test with its issue, and a listed case that passes fails the test (#341) - Added a report of the round-trip tests: each run records the result of each step in
tests/_output/round-trip/,composer round-trip-reportprints the entries to remove, correct or add,composer test-round-tripruns only these tests, andtests/RoundTrip/README.mdhas the steps for a fix. The cause of a known failure is a field of its entry (#396) - Added the step N of the round-trip tests: the normal form of the file column equals the normal form of the column that the database gives back, attribute by attribute (#342)
- Added
UPGRADE.md: the changes of behavior between the versions and the steps for an upgrade, the newest version first, starting with “Upgrade from 5.0.0”. Each change of behavior adds its entry there (#403) - Added the documentation site in
docs/(Astro and nimbus-docs, as the Phalcon documentation site): one folder for each version, 6.0 (in development, the text ofmaster), 5.0 (stable), 4.0, 3.0 and 2.2 (deprecated),docs/servefor a local preview, a changelog page for each version from this file, and the workflowdocs.yml, which builds the site for each change ofdocs/or of this file and publishes it frommasterto migrations.phalcon.io. The folder is not in the Composer package. This file now has the 3.0.0 and 3.0.1 releases, from their GitHub release notes (#413)
Fixed
- Fixed
generateon PostgreSQL removing the primary key column from the other indexes: a composite index(id, name)was written as(name), and a unique index on the primary key column was not written. The generated files of such tables change one time (#304) - Fixed
listIndexes()on PostgreSQL giving the columns of an index in no fixed order, not in the order of the index.generatewrote this order, so a table made from the file could get a different index. The generated files of such tables change one time (#308) - Fixed
listColumns()on PostgreSQL reading a text column withDEFAULT NULL(stored asNULL::character varying) with the default textNULL.generatewrote'default' => "NULL", and a table made from the file gotDEFAULT 'NULL'. The text'NULL'stays a text default. The generated files of such tables change one time (#305) - Fixed
listColumns()on SQLite reading a text default with a quote with two quotes (it''sforit's), and removing all the quotes at the start and the end of a default. The generated files of such tables change one time (#306) - Fixed an incremental version folder with a short name, for example
1.1: the tool read it as the version1.1.0and looked for the folder1.1.0.runskipped it with no message,listshowed1.1.0, andexportstopped with a PHP error. Nowrun,list,exportandgeneratestop before any change with an error that tells the user to rename the folder (#314) - Fixed the morph sending DDL on each run for two kinds of columns: a numeric default of the migration file (a text, for example
"0") and the same default of the table (a number) were a change; on PostgreSQL, a default of the table that the migration file has not was not removed. Now the morph compares a numeric default by its value, and PostgreSQL removes the default (DROP DEFAULT), as MySQL does (#320) - Fixed the morph on SQLite never finding a
TYPE_VARCHARcolumn of the migration file equal to the column of the table: SQLite makesTEXTof it and reads it asTYPE_TEXTwith no size. A rename of such a column dropped the column and its data. Now the compare treatsTYPE_VARCHARasTYPE_TEXTwith no size on SQLite. The DDL and the generated files do not change (#321) - Fixed
run --skip-foreign-checkson PostgreSQL stopping with a raw database error for a role that is not a superuser. Now it stops with a message that names the privilege: a superuser, or on PostgreSQL 15 and later theSETprivilege onsession_replication_role(#322) - Fixed the foreign key checks after a migration with
--skip-foreign-checks: after an error they stayed off, and after the migration they were on also when they were off before. NowMigration::migrate()puts back the value of before (FOREIGN_KEY_CHECKSon MySQL,session_replication_roleon PostgreSQL), also after an error (#323) - Fixed the morph dropping columns, foreign keys and indexes in the current schema of the connection, not in the
schemaof the config where it adds them (MySQL with aschemathat is notdbname). FixeddropPrimaryKey()on PostgreSQL dropping only a primary key with the name<table>_pkey: now it reads the name from the catalog, also for a renamed table or a name that another tool gave (#324) - Fixed the data load for a PostgreSQL boolean
falseand for column names that need quotes. The data file has a boolean as1or0(before,falsewas an empty field, which PostgreSQL rejects); the load reads an empty field of a boolean column asfalse, so the older files load too. TheINSERTof the data quotes each column name (a reserved word such asorder, or a PostgreSQL name in mixed case such asuserId); a name that is already in quotes stays as it is (#327) - Fixed the text
NULL(the four letters) of a text column loading as SQLNULL. The data file now has the textNULLas\NULL; a fieldNULLstays SQLNULL, so the older files keep their meaning (#328) - Fixed the rollback and
exportwith two or more migrations folders. A rollback looked for the earlier definition of a table only in the folder of the version that it rolled back, so the table kept the newer structure;exportgave aCREATE TABLEfor each folder of a table. Now both take the newest definition, not higher than the version, of all the folders (#330) - Fixed many actions in one PHP process depending on the static state of the actions before. Each action (
generate,run,list,export,clean,import-log) now starts with the default state of the log and ofMvc\Model\Migration(Migration::reset(), new). An old-format migration file (a named class) still loads one time for each process (#331) - Fixed each action opening more than one connection to the database.
run,list,cleanandimport-lognow use one connection for the migration and the database log, so SQLite:memory:keeps the tables and the log in one database. With--verbose, the SQL of the log is now also printed (#332) - Fixed
generatewith adescr(from--descror the config) and nots-basedwriting a timestamped version thatrun,listandexportdo not see. Nowgeneratestops with an error and writes nothing (#333) - Fixed the checks of the options of the actions (#334):
- Fixed a file of
generatethat changes each FLOAT, DOUBLE, TEXT and BLOB column again at each run: on MySQL the read gives a size that the file does not have, and on PostgreSQLgeneratewroteTYPE_FLOATfor a double precision column. The morph now compares the normal forms, andgeneratewritesTYPE_DOUBLE(#389) - Fixed
generateon PostgreSQL writing'size' => 1for a VARCHAR column with no length (#390) - Fixed the read of a PostgreSQL column with a comment and a default that is an expression (for example
DEFAULT gen_random_uuid()): it lostdefaultExpression, sogeneratewrote the default as a text, and the file could not make the table on a new database (#398) - Fixed the time precision (decision D1.4): the read gives the precision of a
TIMESTAMP,DATETIMEorTIMEcolumn as itssize, and it reads aCURRENT_TIMESTAMP(n)default and a MySQLON UPDATE CURRENT_TIMESTAMP(n);generatewrites them, and the DDL writesTIMESTAMP(n)and the default with its precision. Before, the precision was lost: a file ofgeneratemade the column with no precision and no default, and on MySQL a change of another attribute of the column removed the precision and the fraction of the values. A column with no precision (0 on MySQL, 6 on PostgreSQL) still has no size in the file, so only the files of a column with a precision change, one time.listColumns()now gives the precision as the size of a time column, for example 0 on MySQL and 6 on PostgreSQL for a column with no precision (#339)generatestops with a clear error for adescrthat is not of the timestamped form (lower case letters and digits, in groups with_between them), and for adata(exportData) value that is notalwaysoroncreate. Before, a wrongdatavalue wrote a new version with no data each time.listAllgives no PHP warning for a missingtsBasedorconfig, and reads amigrationsDirtext, asrundoes. The version guess ofgeneratealso reads amigrationsDirtext, and gives no PHP warning for a missingforce.generatechecks thatconfigis aConfigobject, as the other actions do. The message of this check now says that the caller gave a wrongconfig.- The table names of
--tableand--export-data-from-tablesare trimmed, soa, bis the tablesaandb.
- Fixed
run,listand the version folders (#335):- A logged version with no folder (for example a version of another branch) stopped
runwith no message. Nowrunprints a warning for each such version, and starts from the highest logged version that has a folder. The “Everything is up to date” check compares the sets of versions, not only their number. - An incremental version folder is now only a version (
^\d+(\.\d+)+$). Before, each folder name with a version in it (for example the backup1.0.0-old) ran as a version. Such a folder is now skipped with a notice. listwith many folders continues after a folder with no versions.
- A logged version with no folder (for example a version of another branch) stopped
- Fixed the file log deleting a file named
.phalconin the project folder (when nolog-pathis set). Now the action stops with an error that tells the user to move the file or to setlog-path(#336) - Fixed
generatenot seeing a change of a name withMigration_in it (for example a columnMigration_arenamed toMigration_b). The “no change” check no longer changes the text of the class names. When the newest file of a table is in the old format (a named class), the firstgeneratewrites one new version in the new format; the nextgeneratewrites nothing if no table changed (#337) - Fixed the read of a text default with
CURRENT_TIMESTAMPin it on MySQL and PostgreSQL (for exampleDEFAULT 'Not CURRENT_TIMESTAMP'): it was read as no default, sogenerateleft it out and the morph sent a change at each run. Now only an expression default withCURRENT_TIMESTAMPin it stays out of the read. The generated files of such tables change one time (#402) - Fixed the compare of two table names on MySQL: it ignored the case, also on a server with
lower_case_table_names=0(the default on Linux), wherePhalcon_Migrationsandphalcon_migrationsare two tables, sogenerateandruntook such a table for the log table. Now the compare readslower_case_table_namesof the server one time for each connection: with0the case matters (decision D2.4) (#343) - Fixed
run --skip-foreign-checkson SQLite: it did not change the foreign key checks. Now it turnsPRAGMA foreign_keysoff for the migration and puts back the value of before, also after an error (#343) - Fixed the morph not applying a change of the column order or the type of an index, or of the actions or the referenced schema of a foreign key: it compared an index only by its name and its set of columns, and a foreign key only by its tables and its sets of columns. Now the morph compares the keys in the form in which the database stores them, drops the foreign keys first and adds them last.
CREATE TABLEon MySQL also writesUNIQUE KEYfor the index typeuniquein lower case. The round-trip tests have a new step K: the keys that the database gives back equal the keys of the file (#393) - Fixed the second morph of a table on PostgreSQL when the file gives the primary key index with the name
PRIMARY(the form of the documentation and of the files ofgenerateon MySQL): the morph added the primary key again, and PostgreSQL stopped withmultiple primary keys. Now the morph pairs the primary key by its type, not by its name (#386) - Fixed a change of the columns of a foreign key on MySQL: the morph stopped with
1061 Duplicate key name, because MySQL keeps the index of the dropped foreign key. Now the morph also drops that index, when the file has no index with that name (#361) - Fixed the second morph on MySQL of a file with a list of indexes and a foreign key: the morph dropped the index that MySQL made for the foreign key, and MySQL stopped with
1553. Now the morph keeps an index with the name of a foreign key of the table (#405) - Fixed the second morph of a file that gives the primary key with the column flag
primaryand also has a list of indexes: the morph dropped the primary key (MySQL), or stopped with an error (PostgreSQL). Now the columns with the primary flag are the primary key of the file when its indexes have no primary key (#406) - Fixed
generatestopping with aTypeErroron MySQL and SQLite for a table with an index on an expression (for examplelower(email)), and writing such an index on PostgreSQL as an index on its columns only. The adapters now givenullfor a part of an index on an expression (Index::hasExpression(), new);generateleaves such an index out of the file with a message, and the morph does not drop or change it (#391) - Fixed
generatewith incremental versions stopping withDirectoryIterator::__construct(...): Failed to open directorywhen a folder of amigrationsDirlist does not exist. The user selects one folder of a list, and only that folder is made. Now a folder that does not exist has no versions, as in the compare ofgenerate(#364)
Changed
- Changed the code for the small SonarQube code smell findings: constants for repeated texts,
includewith no parentheses, the checks for an empty array, no nested ternary, and the arguments of the descending sort. No change of behavior (#297) - Changed the octocov coverage floor from 88.0% to the measured value, 99.0% (#351)
- Changed the data export of
generate --data: the rows are in the order of the primary key, when the table has one, so that two exports of the same data give the same file (the.datfiles can change one time at the nextgenerate). On MySQL, the export reads the rows one at a time (an unbuffered query), so that a large table is not all in memory (#329) - Changed the database servers of the tests to versions that have support: MySQL 8.4 (was 8.0) in CI and in
docker-compose.yml, and PostgreSQL 18 (was 14) in CI. The localdocker-compose.ymlalready used PostgreSQL 18. MySQL 8.0 and PostgreSQL 14 are at end of life (#387) - Changed the round-trip tests: the failure of the step R lists the statements of the rename, and the skip line shows the line of the failure that has the text of the known failure. The data-loss entries now match the drop of the old column (#394)
- Changed the compare of the morph and the columns of
generate: each database has a dialect class (Phalcon\Migrations\Db\Dialect, internal) with its type tables and the normal form of a column, the form in which the database stores it. The morph compares the normal forms, so a type that the database stores as another type, a size that it does not keep, or an attribute that it does not store gives no change at each run, and a rename of such a column keeps its data.listColumns()gives the same result as before. The files ofgeneratecan change one time: on PostgreSQL a FLOAT or DOUBLE PRECISION column isTYPE_DOUBLE(wasTYPE_FLOAT), and a VARCHAR with no length has no size (was 1); on SQLite each column has the type that SQLite stores, with no size (for exampleTYPE_TEXTfor VARCHAR and CHARACTER,TYPE_INTEGERfor BIGINT and TINYINT,TYPE_DATETIMEfor TIMESTAMP,TYPE_FLOATfor DOUBLE).generatethen writes one new version for each such table, one time (#342) - Changed the rules of each database in
Mvc\Model\Migration,Connectionand the adapters: the quote of a name, the default schema, the compare of two table names and the switch of the foreign key checks are methods of the dialect classes (Phalcon\Migrations\Db\Dialect, internal), with one copy of each rule.Connection::quoteIdentifier()needs no connection.Migration::isSameTable()has a new optional parameter, the adapter for the read of the MySQL setting (#343)