Comments (6)
Hi Felix:
We've stopped using non-elidable migrations. There's no reason to use them when you can perform the same logic using post_migration signals (from django.db.models.signals import post_migrate). We moved all logic that we were trying to keep in non-elidable migration operations into functions that run after migrations.
--Phil.
from django-squash.
Hi @philfriesen , by reading your docs, you inspired me to actually do the same for almost all of my non-elidable migrations and I'm super happy with the result! It is more maintainable and reliable like that. Thanks a lot for the pattern!
I don't understand however how you can put BtreeGistExtension()
somewhere else than in a migration, do you have a technique to do that?
Thanks!
from django-squash.
What do your models look like?
from django-squash.
We put it in our DB creation scripts:
`
DROP DATABASE IF EXISTS your_db_name;
CREATE DATABASE your_db_name WITH ENCODING 'UTF8' LC_CTYPE 'en_US.UTF-8' LC_COLLATE 'en_US.UTF-8' TEMPLATE TEMPLATE0;
GRANT ALL PRIVILEGES ON DATABASE your_db_name TO your_db_role_aka_user;
\connect your_db_name;
create extension if not exists hstore schema pg_catalog;
`
from django-squash.
From what I can see (very shallow reading) about using HStoreField
, ExclusionConstraint
, etc., is you currently need to manually add your own BtreeGistExtension
/BtreeGisExtension
/etc after running makemigrations
to the migration file that gets created. The idea of having you add these operations manually rubs me the wrong way, but unfortunately at the moment, if core django does not support it, I would have to follow their lead and say we won't either :/
django-squash
at the most basic level is a wrapper around makemigrations
that is "squash aware", "when" or "if" django decides to add this automatic functionality to makemigrations
we will benefit automatically.
from django-squash.
@kingbuzzman great ok I understand, yes indeed it's up to me to add this extension or not.
I was just thinking that, since running manage.py squash_migrations
does keep the RunPython
migrations (and it's then up to me to delete them or not), then it would also be possible to keep the Postgres extensions migrations and leave it up to me to remove them or not.
No problem if it's not possible I will have to be very careful when running the command!
@philfriesen thanks, for now we would like to avoid having to write raw sql although we will certainly have to some day!
from django-squash.
Related Issues (7)
- Optional auto adding namespace the functions used in the code and reverse_code arguments of RunPython HOT 6
- Touches migrations inside site-packages HOT 4
- 6/site-packages/django_squash/apps.py", line 2, in <module> from django.db.migrations.serializer import Serializer HOT 2
- IndexError: list index out of range HOT 4
- Hello again, sorry I missed your answer. So I plan to reopen issue, cause I tried to squash my migrations again :) HOT 4
- NameError: name 'RunPython' is not defined HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-squash.