Project Laravel works in mysql but the error in the migration when using postgres

1

I have a project that I started in mysql, I created some migration and I put relationships inside them, whenever I needed to make changes, delete the database and run the migrate again, with mysql always worked.

I need to change the database for postgress, but it is causing me an error when I run the migrate, because in the order of execution of the migrate files they are related to some tables that do not yet exist (they will be created in the next files).

Is there any way I can get postgres to ignore these errors until the artisan runs the next files?

The error message is as follows:

  

[Illuminate \ Database \ QueryException]
  SQLSTATE [42P01]: Undefined table: 7 ERROR: relation "trips" does   not exist (SQL: alter table "products" add constraint   "foreign_products_id_foreign" foreign key ("viaje_id") references   "trips" ("id"))

     

[PDOException]
    SQLSTATE [42P01]: Undefined table: 7 ERROR: relation "trips" does not exist

    
asked by anonymous 17.11.2017 / 20:37

2 answers

0

Friend probably your foreign key is getting ready for a table that has not yet been created.

1) Make sure the table name in the reference is correct.

2) Verify that prefix in timestamp at the beginning of the product migration file is greater than the timestamp prefix of the travel file.

I hope I have helped

    
18.11.2017 / 17:16
0

Just for registration, if someone arrives here with the same problem, the error was occurring because of the mysql engine configuration, in my WAMP development environment, he was using MyISAM by default, in the production environment, it was being used the InnoDB, this second makes a series of checks on the foreign keys.

The solution found was to edit the database.php file inside the config folder, and set the line 'engine' = > null for 'engine' = > 'MyISAM', after that the code worked normally.

    
28.11.2017 / 00:20