-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration (--migrationPath) #9698
Comments
There's currently no way doing it automatically. |
Alternative https://github.com/deesoft/yii2-console // params.php
return [
'dee.migration.path' => [
'@yii/rbac/migrations',
'@mdm/autonumber/migrations',
'@mdm/upload/migrations',
]
]; |
modify the database would be the best way? and change the getMigrationHistory() (in yii\console\controllers\MigrationController) to modify the basePath Attribute based on the value of the database |
I think the best way to solve it is to create bash script that runs a couple of commands specifying necessary |
if you want to use " migrate/redo all or migrate/down all"? bash script not works for this case use. |
Why? |
how @mubushi said "when i run the command without the parameter migrationPath in a migration that is not in the default directory y get the exception failed to open stream: No such file or directory' obviously " if you want to run migrate/up you have create bash script, if you want to run migrate/down you have create another bash script again. when you have many migrations and modules do this is difficult, i think to this feature should be include out of the box. |
Not really another. It's about adding more lines to existing |
when you have new migration you have to include it in migrate_down.sh and migrate_up.sh, it is little troublesome. I think to this feature should be handle framework. it simplify development. |
Not when you have new migration but when you have new path for migrations such as new module. That's the same with configs — with each new module you have to add another path to config file. |
sorry, i dont understand. if i want to "migrate/redo all" for example how do you do it? in the following case how do you do it?
|
Yes: ./yii migrate/redo all
./yii migrate/redo all --migrationPath=module1/foo/migrations
./yii migrate/redo all --migrationPath=module2/foo/migrations
./yii migrate/redo all --migrationPath=module3/foo/migrations |
@samdark I think you dont understand me. For example i run the following steps : 1º i create migration test1 in default path and run migrate when i run yii migrate/redo it throws an exception obviusly : |
The most proper way to solve such problem would be usage of the namespaces for migrations insteand of paths. |
@pana1990 then you commit all these migrations into repository and another developer who's in your team is trying to apply them. How would they do that? |
@klimov-paul yes, that could solve the issue. |
@samdark mmm, it's truth. In rails resolve this issue with schema dump. For more details http://guides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you |
hi guys, @klimov-paul, @samdark , @pana1990 , sorry for the inactivity.
is the better and simple way to solve this issue. |
+1 for @klimov-paul solution. Migrations should use namespaces at least to be consistent. Working with many modules with migrations can be really cumbersome. |
A simple way to solve this problem and still keep BC is add new property to migration controller e.g 'controllerMap' => [
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationLookup' => [
'@yii/rbac/migrations',
'@another/ext/migrations',
],
]
] Then, we just change simple code in PS: We dont need to change table schema. |
hi @mdmunir, the database schema does not change, just the whole class name (all namespace) in the "version" field in the table would be stored. |
@mubushi And what about previous migration file that not in the namespaced class? Is it still compatible? |
@mdmunir I believe that the above files are supported, during migrate / down yii find the file, even if does not have namespace as said @klimov-paul
and solves the problem of locating migration in turning back . but what you propose I like, because it would not specify the migration path migrate / up and would not have to make many changes XD. |
I think the best to solved this is to use namespaces and a namespace Acme\Sihpments\migrations;
use yii\db\Migration;
class ShipmentLog extends Migration
{
$depends = [
'Acme\Shipments\migration\Shipment'
];
} Then use two tables in the |
Solution proposed at #12511 |
Resolved by commit 8aa0e85 |
@klimov-paul are the solution backward compatible? |
yes, it should be |
@klimov-paul |
The file path will NOT be saved - it was never promised. |
That what i mean. The migration does not remember migration path. |
Several migration path will not be supported - this decision is final. |
hi all, sorry for any inconvenience
when making a migration indicating the migrationPath, for example:
yii does not save the migration path used in migration. So when I run the command down, I have to specify the migrationPath for each migration or grup. but when many migrations, this becomes a problem.
when i run the command without the parameter migrationPath in a migration that is not in the default directory y get the exception failed to open stream: No such file or directory' obviously
with many migrations and modules do this is difficult, I think yii should store the migrationPath used for each migration.
something like change the migration table to :
if there is a way to do it, let me note. thk team :D
The text was updated successfully, but these errors were encountered: