You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe what you are trying to achieve and what goes wrong.
I dumped my SQL to the database (Postgres 9.4) and used devtools to generate ts-based migration files stored in db afterwards. All went well. However, after dropping the database and creating afresh, then attempting to run the same migrations generated by devtools (just simulating a fresh deployment), the migration fails with an error :
ERROR: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "public.client" does not exist"
I observed, the migrations may have been generated in a random order and so in an attempt to run on a fresh environment, the foreign table referenced may not have been created. Thus leading to errors.
Expected behaviour:
Generate migration files from db with reference to defined foreign relationships, ensuring referenced tables get created first in the hierarchy.
Provide output if related
`ERROR: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "public.client" does not exist"`
Provide minimal script to reproduce the issue
Files listed in the order they were generated by phalcon devtools
Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.4.0
Build Date => Jun 6 2018 04:54:09
Powered by Zephir => Version 0.10.10-d1b4cc68d9
Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.disable_assign_setters => Off => Off
PHP Version: (php -v)
PHP 7.2.7-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jun 22 2018 08:44:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.0alpha1, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.2.7-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Operating System:
MacOs High Sierra - running docker instance
Server: Nginx | Apache | Other
Nginx
Other related info (Database, table schema):
Postgres
The text was updated successfully, but these errors were encountered:
chibuzoro
changed the title
Running migrations with foreign key references on empty database fails
Running generated migrations with foreign key references on empty database fails
Sep 2, 2018
Expected and Actual Behavior
I dumped my SQL to the database (Postgres 9.4) and used devtools to generate ts-based migration files stored in db afterwards. All went well. However, after dropping the database and creating afresh, then attempting to run the same migrations generated by devtools (just simulating a fresh deployment), the migration fails with an error :
ERROR: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "public.client" does not exist"
I observed, the migrations may have been generated in a random order and so in an attempt to run on a fresh environment, the foreign table referenced may not have been created. Thus leading to errors.
References to similar issue:
Expected behaviour:
Generate migration files from db with reference to defined foreign relationships, ensuring referenced tables get created first in the hierarchy.
`ERROR: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "public.client" does not exist" `
Files listed in the order they were generated by phalcon devtools
Details
System info and versions (if possible): (
phalcon info
)Environment:
OS: Linux edcef3d10fee 4.9.93-linuxkit-aufs Easier installation on Linux and OSX phalcon-devtools#1 SMP Wed Jun 6 16:55:56 UTC 2018 x86_64
PHP Version: 7.2.7-1+ubuntu16.04.1+deb.sury.org+1
PHP SAPI: cli
PHP Bin: /usr/bin/php7.2
PHP Extension Dir: /usr/lib/php/20170718
PHP Bin Dir: /usr/bin
Loaded PHP config: /etc/php/7.2/cli/php.ini
Versions:
Phalcon DevTools Version: 3.4.0
Phalcon Version: 3.4.0
AdminLTE Version: 2.3.6
Phalcon Framework version: (
php --ri phalcon
)phalcon
Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.4.0
Build Date => Jun 6 2018 04:54:09
Powered by Zephir => Version 0.10.10-d1b4cc68d9
Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.disable_assign_setters => Off => Off
php -v
)PHP 7.2.7-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jun 22 2018 08:44:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.0alpha1, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.2.7-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
MacOs High Sierra - running docker instance
Nginx
Postgres
The text was updated successfully, but these errors were encountered: