You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specifying storedAs() (guessing virtualAs has the same problem) on a column change in a migration doesn't apply the generated column expression, silently leaving you with plain column rather than a generated one. This may be a Doctrine DBAL issue since it involves change(), but figured I'd file the issue where I experienced it.
Steps To Reproduce:
In one migration:
Schema::create('urls', function (Blueprint$table) {
$table->bigIncrements('id');
$table->json('response');
$table->string('click_url')->storedAs("response->>'$.click_url'");
});
At this point you'll see the correct generated column in SHOW CREATE TABLE urls.
But once you run this:
Schema::table('urls', function (Blueprint$table) {
$table->string('click_url', 4096)->storedAs("response->>'$.click_url'")->change();
});
You get the longer field length but lose the generated-ness.
The text was updated successfully, but these errors were encountered:
fyi for anyone else affected, doctrine are waiting for a PR to add support to doctrine/orm for marking fields as not updateable / not insertable so that they can stop ignoring generated fields.
in the mean time, you could quite safely work around this as so:
Schema::create('urls', function (Blueprint$table) {
$table->bigIncrements('id');
$table->json('response');
$table->string('click_url')->storedAs("response->>'$.click_url'");
});
Schema::table('urls', function (Blueprint$table) {
$table->dropColumn('click_url');
});
Schema::table('urls', function (Blueprint$table) {
$table->string('click_url', 4096)->storedAs("response->>'$.click_url'")->after('response');
});
since the column is generated there won't be any data loss.
Description:
Specifying storedAs() (guessing virtualAs has the same problem) on a column change in a migration doesn't apply the generated column expression, silently leaving you with plain column rather than a generated one. This may be a Doctrine DBAL issue since it involves change(), but figured I'd file the issue where I experienced it.
Steps To Reproduce:
In one migration:
At this point you'll see the correct generated column in
SHOW CREATE TABLE urls
.But once you run this:
You get the longer field length but lose the generated-ness.
The text was updated successfully, but these errors were encountered: