I can traslate model to db and db to model. I think is great!!! I can auto-generate migrations.
A client of mine has started a job without migrations. He has a lot of tables. I need to create schema with migration now. But I cant.
Maybe with DumpSchemaCommand I'll can. Thank you @schmunk
I think there is no need to reproduce an existing database in migrations - too much work without any benefit.
Migrations are great when they are connected to a code changes - you can checkout an older source version and get an appropriate DB state.
And I had the same situation - our current project was started without migrations and then we switched to db changes via migrations. Here even if we re-build db structure with migrations it will be still the same signle state, because you can not put migrations into previous appropriate commits with code changes.
Our solution is this: we have one solid SQL script "init.sql" (initial database state before migrations) and migrations applied on top of it.
This initial "init.sql" script can be created using console command like schmunk suggested or using mysqldump util or via phpmyadmin (actually any tool which can dump a database into a script).
To re-create a current database (for example, on test server) we use a shell script which creates database, loads "init.sql" and then run migrations.
To upgrade an existing database to the latest version we just run "yiic migrate up".