Skip to content

Changelog

The changes of each release of Phalcon Migrations 6.0.

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), InvalidArgumentException and Color, and the fake tests/Fakes/Utils/FakeStdinWrapper for php://stdin (#299)
  • Added tests for the code coverage of the CLI command: the clean, export, list and migrate-files actions, the default migrations folders, a relative migrations folder of the config, and the search for config/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 NULL and a reference with no name; the MySQL first column position and a reference with no name; Generate::createDumpFiles() with a connection and getCode() before createEntity() (#303)
  • Added tests for the code coverage of Migrations: the errors of the actions (no folder, no config, no adapter), export with a table name and with a file that has no morph, generate and run with a table prefix or names, the version column of list, a rollback over a version that did not run, the paths and the errors of the file log, and import-log with a version that does not fit (#313)
  • Added tests for the code coverage of Mvc\Model\Migration: the errors of morphTable() (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 hooks afterUp(), afterDown() and afterCreateTable(), and the errors of the class loader (#317)
  • Added tests for the escaped Infection mutants of the small classes: addMinor() and the stamp of IncrementalItem, the compare of an incremental and a timestamped version, the timestamped version pattern, the folder question of Helper (the new fake tests/Fakes/Utils/FakeStdoutFilter for STDOUT), Camelize with a dash between delimiters and with a multibyte letter, the output of Profiler and DbProfilerListener, and ListTablesDb on 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 of Column; the flags, the position and a size or scale of 0 of PhalconColumnBridge; the compare of the auto increment and of a null default of FieldDefinition; the actions of Reference (#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() and emptyTables() (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 Generate and Mvc\Model\Migration: the checks before createEntity(), the defaults of the add*() methods and of createDumpFiles(), 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 of setup(), isSameTable() on PostgreSQL, migrate() to the same version, the batches of batchInsert(), the collect mode of getTableDefinition(), 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 of listAll(), generate(), clean(), run() and importLog(), 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 of importLog(), 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 of generate() 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 migration and migrate-files commands (the files tests/_data/console/*.txt), the text of each message style of Color and its terminal check, the messages of migrate-files, the options that the command gives to generate, run, list and clean, the config in app/config/ and in an ini file, a JSON extension, and the version of OptionStack (the type, an existing version, the newest version of all the folders) (#366)
  • Added pgsql (the PDO name) as an alias of postgresql for the adapter of the config. postgresql stays 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 generate sends 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-report prints the entries to remove, correct or add, composer test-round-trip runs only these tests, and tests/RoundTrip/README.md has 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 of master), 5.0 (stable), 4.0, 3.0 and 2.2 (deprecated), docs/serve for a local preview, a changelog page for each version from this file, and the workflow docs.yml, which builds the site for each change of docs/ or of this file and publishes it from master to 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 generate on 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. generate wrote 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 with DEFAULT NULL (stored as NULL::character varying) with the default text NULL. generate wrote 'default' => "NULL", and a table made from the file got DEFAULT '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''s for it'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 version 1.1.0 and looked for the folder 1.1.0. run skipped it with no message, list showed 1.1.0, and export stopped with a PHP error. Now run, list, export and generate stop 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_VARCHAR column of the migration file equal to the column of the table: SQLite makes TEXT of it and reads it as TYPE_TEXT with no size. A rename of such a column dropped the column and its data. Now the compare treats TYPE_VARCHAR as TYPE_TEXT with no size on SQLite. The DDL and the generated files do not change (#321)
  • Fixed run --skip-foreign-checks on 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 the SET privilege on session_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. Now Migration::migrate() puts back the value of before (FOREIGN_KEY_CHECKS on MySQL, session_replication_role on 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 schema of the config where it adds them (MySQL with a schema that is not dbname). Fixed dropPrimaryKey() 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 false and for column names that need quotes. The data file has a boolean as 1 or 0 (before, false was an empty field, which PostgreSQL rejects); the load reads an empty field of a boolean column as false, so the older files load too. The INSERT of the data quotes each column name (a reserved word such as order, or a PostgreSQL name in mixed case such as userId); 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 SQL NULL. The data file now has the text NULL as \NULL; a field NULL stays SQL NULL, so the older files keep their meaning (#328)
  • Fixed the rollback and export with 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; export gave a CREATE TABLE for 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 of Mvc\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, clean and import-log now 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 generate with a descr (from --descr or the config) and no ts-based writing a timestamped version that run, list and export do not see. Now generate stops with an error and writes nothing (#333)
  • Fixed the checks of the options of the actions (#334):
  • Fixed a file of generate that 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 PostgreSQL generate wrote TYPE_FLOAT for a double precision column. The morph now compares the normal forms, and generate writes TYPE_DOUBLE (#389)
  • Fixed generate on PostgreSQL writing 'size' => 1 for 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 lost defaultExpression, so generate wrote 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, DATETIME or TIME column as its size, and it reads a CURRENT_TIMESTAMP(n) default and a MySQL ON UPDATE CURRENT_TIMESTAMP(n); generate writes them, and the DDL writes TIMESTAMP(n) and the default with its precision. Before, the precision was lost: a file of generate made 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)
    • generate stops with a clear error for a descr that is not of the timestamped form (lower case letters and digits, in groups with _ between them), and for a data (exportData) value that is not always or oncreate. Before, a wrong data value wrote a new version with no data each time.
    • listAll gives no PHP warning for a missing tsBased or config, and reads a migrationsDir text, as run does. The version guess of generate also reads a migrationsDir text, and gives no PHP warning for a missing force.
    • generate checks that config is a Config object, as the other actions do. The message of this check now says that the caller gave a wrong config.
    • The table names of --table and --export-data-from-tables are trimmed, so a, b is the tables a and b.
  • Fixed run, list and the version folders (#335):
    • A logged version with no folder (for example a version of another branch) stopped run with no message. Now run prints 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 backup 1.0.0-old) ran as a version. Such a folder is now skipped with a notice.
    • list with many folders continues after a folder with no versions.
  • Fixed the file log deleting a file named .phalcon in the project folder (when no log-path is set). Now the action stops with an error that tells the user to move the file or to set log-path (#336)
  • Fixed generate not seeing a change of a name with Migration_ in it (for example a column Migration_a renamed to Migration_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 first generate writes one new version in the new format; the next generate writes nothing if no table changed (#337)
  • Fixed the read of a text default with CURRENT_TIMESTAMP in it on MySQL and PostgreSQL (for example DEFAULT 'Not CURRENT_TIMESTAMP'): it was read as no default, so generate left it out and the morph sent a change at each run. Now only an expression default with CURRENT_TIMESTAMP in 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), where Phalcon_Migrations and phalcon_migrations are two tables, so generate and run took such a table for the log table. Now the compare reads lower_case_table_names of the server one time for each connection: with 0 the case matters (decision D2.4) (#343)
  • Fixed run --skip-foreign-checks on SQLite: it did not change the foreign key checks. Now it turns PRAGMA foreign_keys off 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 TABLE on MySQL also writes UNIQUE KEY for the index type unique in 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 of generate on MySQL): the morph added the primary key again, and PostgreSQL stopped with multiple 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 primary and 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 generate stopping with a TypeError on MySQL and SQLite for a table with an index on an expression (for example lower(email)), and writing such an index on PostgreSQL as an index on its columns only. The adapters now give null for a part of an index on an expression (Index::hasExpression(), new); generate leaves such an index out of the file with a message, and the morph does not drop or change it (#391)
  • Fixed generate with incremental versions stopping with DirectoryIterator::__construct(...): Failed to open directory when a folder of a migrationsDir list 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 of generate (#364)

Changed

  • Changed the code for the small SonarQube code smell findings: constants for repeated texts, include with 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 .dat files can change one time at the next generate). 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 local docker-compose.yml already 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 of generate can change one time: on PostgreSQL a FLOAT or DOUBLE PRECISION column is TYPE_DOUBLE (was TYPE_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 example TYPE_TEXT for VARCHAR and CHARACTER, TYPE_INTEGER for BIGINT and TINYINT, TYPE_DATETIME for TIMESTAMP, TYPE_FLOAT for DOUBLE). generate then writes one new version for each such table, one time (#342)
  • Changed the rules of each database in Mvc\Model\Migration, Connection and 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)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close