mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
Operations documentation
This commit is contained in:
parent
8146186447
commit
30f7835cef
@ -22,13 +22,27 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
This page is useful for custom migration tricks.
|
||||||
|
Sometimes, when you need to have a migration hack and you think it can be
|
||||||
|
useful again, put it there, we never know if we might need the hack again.
|
||||||
|
"""
|
||||||
|
|
||||||
from django.db import connection, migrations
|
from django.db import connection, migrations
|
||||||
|
|
||||||
|
|
||||||
class PsqlRunOnly(migrations.RunSQL):
|
class PsqlRunOnly(migrations.RunSQL):
|
||||||
"""
|
"""
|
||||||
Usefull for migrations with specific postgresql commands
|
This is an SQL runner that will launch the given command only if
|
||||||
Avoid breaking tests and local dev environnment
|
the used DBMS is PostgreSQL.
|
||||||
|
It may be useful to run Postgres' specific SQL, or to take actions
|
||||||
|
that would be non-senses with backends other than Postgre, such
|
||||||
|
as disabling particular constraints that would prevent the migration
|
||||||
|
to run successfully.
|
||||||
|
|
||||||
|
See `club/migrations/0010_auto_20170912_2028.py` as an example.
|
||||||
|
Some explanations can be found here too:
|
||||||
|
https://stackoverflow.com/questions/28429933/django-migrations-using-runpython-to-commit-changes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _run_sql(self, schema_editor, sqls):
|
def _run_sql(self, schema_editor, sqls):
|
||||||
|
Loading…
Reference in New Issue
Block a user