5 ms·
Is there any equivalent for django+mysql? I historically found more tools for online schema changes in the mysql sphere, such as gh-ost ( https://github.com/git
by etaioinshrdlu 8y ago
Is there any equivalent for django+mysql? I historically found more tools for online schema changes in the mysql sphere, such as gh-ost ( https://github.com/github/gh-ost https://github.com/github/gh-ost )
- Doxin 8y agoI'm not even sure this is possible in mysql. Last time I checked mysql still couldn't do DDL statements in a transaction.
- lloeki 8y agoLast time I checked MySQL even silently commits out of the transaction and proceeds with the remainder of the queries. Here are the "implicit commit" statements: https://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html https://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html
- fredley 8y agoIn Django it doesn't, it just dumps you out with a fucked-up semi-migration that takes you 20 minutes to get back to a consistent state...
- Doxin 8y agoHonestly I don't see a single good reason for any new project to use mysql over postgres. mysql is almost universally terrible at actually being a database.
- leowoo91 8y agoAfaik mysql migrations doesn't have transactions in Django.
- rantanplan 8y agogh-ost is hardly useful for anyone outside of github. It's predicated on the fact that you don't use foreign keys. Now why would someone use MySQL without FKs... is beyond me, but I'm sure they have their reasons. MySQL has this https://dev.mysql.com/doc/refman/5.6/en/innodb-online-ddl.html https://dev.mysql.com/doc/refman/5.6/en/innodb-online-ddl.ht... for Online Schema migration and MariaDB has ALTER ONLINE https://mariadb.com/kb/en/library/alter-table/ https://mariadb.com/kb/en/library/alter-table/ They both work with triggers + ghost tables, so they don't need transactions.
- orf 8y agoRails does not use foreign keys by default.
- rantanplan 8y agoWhat does "by default" mean? If you want to have referential integrity there's no other choice. Otherwise you create tables that have no relation to each other. No one stops you from doing this, but then you probably don't want an RDBMS in the first place.
- orf 8y agoRails by default does not add a foreign key constraint at the database level when defining a relationship[1]. And once you have a fairly large rails app that uses this default it's somewhat tricky to migrate. It's madness, I know. 1. https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_reference https://api.rubyonrails.org/classes/ActiveRecord/ConnectionA...
- rantanplan 8y agoWTF! Thanks for that tidbit, I have no XP with Rails, but I would never imagine they do something so atrocious.
- lloeki 8y agoThe rationale is that non-trivial conditions on ActiveRecord model associations can be quite dynamic (possibly implying ruby code evaluation), therefore constraints are best handled at the model level, or else the constraints would only be partially checked at the db level, or even conflicting with the models (e.g if a constraint is to be enforced based on some condition evaluated at runtime, like a simple if clause, or when using STI or polymorphism).
- rantanplan 8y ago