fizz
fizz copied to clipboard
Housekeeping, implement better SQLite DDL, resolve pesky bugs
~This PR adds support for DROP COLUMN without the temp table dance as DROP COLUMN is now officially supported in SQLite 🎉 ~ I had to revert this due to implicit implications on foreign keys and indices :/
It also resolves the notorious "null": false issue.
Additionally, this patch adds new functionality to add_column, allowing to define a foreign key when creating a column. This works for all databases and adds support for introducing foreign keys to SQLite schemas after a table has been created (not possible previously):
ddl := `ALTER TABLE "users" ADD COLUMN "mycolumn" TEXT NOT NULL DEFAULT 'foo' CONSTRAINT projects_subscription_id_fk REFERENCES subscriptions (id, kid) ON DELETE RESTRICT ON UPDATE NO ACTION;`
schema.schema["users"] = &fizz.Table{}
res, _ := fizz.AString(`add_column("users", "mycolumn", "string", {"default": "foo", "size": 50, "foreign_key": {
"table": "subscriptions",
"columns": ["id", "kid"],
"name": "projects_subscription_id_fk",
"on_delete": "RESTRICT",
"on_update": "NO ACTION"
}})`, sqt)
This PR also upgrade PostgreSQL and CockroachDB and MySQL to supported versions as the versions used previously were no longer maintained.
I have updated all the tests and integration tests also. Yay!
Closes #110 Closes #62
Sorry, this PR grew in scope rather quickly. I resolved many bugs though in MySQL and SQLite...
I found another bug in SQLite where the internal meta schema was not appropriately updated on rename_column. During review, I think you can ignore the test stubs and just focus on *.go files :)
And another one, this time it's rename_table, also not correctly updating the meta schema representation.
Oh! @aeneasr, do you still working on this PR? I am currently cleaning up all sub-modules for buffalo and just want to know if you are still working on it.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment. Otherwise, this will be closed in 7 days.
This PR was closed because it has been stalled for 45+7 days with no activity.