atk4 / schema

Few classes built on top of Agile Data that can take care of your SQL database schema
https://agiletoolkit.org/
MIT License
4 stars 5 forks source link

Feature/model integration #4

Closed romaninsh closed 6 years ago

romaninsh commented 6 years ago

Schema migration class should be friendly with Agile Data. This PR adds the following features:

How to use:

$m = new Migration(new User($db));
$m->migrate(); // make sure table for User exists and has correct fields.

// or

$m = new Migration($db);
$m->fromTable('stats');
$app->add('CRUD')->setModel($m->exportModel());
romaninsh commented 6 years ago

Adding BC-Break, because "Migration" can no longer be used. Developer should replace it with either Migration\MySQL or Migration\SQLite.

romaninsh commented 6 years ago

Migration now works as before, but using sub-class is advised.

dvc commented 6 years ago

Production development requires not only schema create/update, but also:

We need tool to (semi)auto support DDL evolution process, not only SQL mapping. Like doctrine-migrations.

I`m not clear understand how to do this in your pattern? Do you have enough metadata for this?

romaninsh commented 6 years ago

@dvc, clearly no. I do not think this project can substitute "doctrine-migrations". Perhaps over time it will be comparable.

For now this implementation allows to extract structure as defined in model's persistence-specific configuration and apply it to SQL databases. The goal for now is to wrap "migrations" into a friendly Wizard (https://github.com/atk4/ui/pull/305).

Regarding histories - there is nothing of this sort, i suppose we can store migrations in files than track which migrations have been applied and which not, but that's some idea for the future. Other ideas can also be added as a ticket. We can discuss how to implement them, but I'd probably need to investigate alternative products first, so please link to any other implementations.

dvc commented 6 years ago

@romaninsh, thank you for the answer.

Now i understand, that in my real projects better to try using both doctrine and atk4.

And more realistic issue to try import doctrine mapping configuration (or any other ORM) to atk4 Models.