I am currently working with apiato framework, as I already create tables and run migrate command, it will create a table but once I want to modify the existing table, therefor I need to run php aristan migrate:fresh
which all the data of all the table will be deleted.
Do you have any other way which I can simply modify my migration code and update to database server without delete all existing data added?
Asked
Active
Viewed 127 times
1

Mochi
- 123
- 8
-
I'm not familiar with laravel or apiato but I would be surprised if you could not ALTER a table given this is a mysql ddl option. – P.Salmon Jun 16 '22 at 08:29
-
We have a migration file which we write each column of a table there like this Schema::create('customers', function (Blueprint $table) { $table->increments('id'); $table->string('customer_name')->nullable(); $table->string('customer_email')->nullable(); $table->timestamps(); $table->softDeletes(); }); so if later I modify this file for example create a new column, it won't affect my existing table – Mochi Jun 16 '22 at 08:36
2 Answers
0
Editing a whole migration file especcially in production is not good. better way to do this is create a new migration for you editing. for example if you want to add a column in a table, create a migration called:
add_<column_name>_to_<table_name>_table
Having said that, migrate a single file wont change your whole db and just refresh a single file. In order to that simply run :
php artisan migrate:refresh --path=<path_to_your_migration_file>
in you are using apiato, directory should be something like
Containers/<container_name>/Data/Migrations/<migration_file_name>
Hope that works for you.

saeed mzr
- 101
- 5