atk4 / data

Data Access PHP Framework for SQL & high-latency databases
https://atk4-data.readthedocs.io
MIT License
273 stars 46 forks source link

How to schema->upgrade() ? #1166

Closed Vladzimir closed 8 months ago

Vladzimir commented 8 months ago

This code not work!

$m->onHook(Model::HOOK_ROLLBACK, function (Model $m, \Throwable $exception) {
    if ($exception instanceof SqlException) {
        $m->schema->upgrade();
        $m->breakHook(false); // exception will not be thrown
    }
});
mvorisek commented 8 months ago

TBH, I do not know what you mean, what is $m->schema, what is schema->upgrade()?

Github issues are not free support. Fell free to discuss your usecase on our Discord forum though.

Vladzimir commented 8 months ago

https://atk4-data.readthedocs.io/en/develop/hooks.html?highlight=upgrade#onrollback-hook Upgrade schema:

mvorisek commented 8 months ago

To upgrade a schema, create Migrator, setup it like you would for create, and then use Doctrine DBAL directly to apply the $migrator->table. Help with docs welcomed.