Code Monkey home page Code Monkey logo

Comments (6)

philfriesen avatar philfriesen commented on July 21, 2024

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.

felixmeziere avatar felixmeziere commented on July 21, 2024

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!

image

from django-squash.

kingbuzzman avatar kingbuzzman commented on July 21, 2024

What do your models look like?

from django-squash.

philfriesen avatar philfriesen commented on July 21, 2024

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.

kingbuzzman avatar kingbuzzman commented on July 21, 2024

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.

felixmeziere avatar felixmeziere commented on July 21, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.