File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed
wger/nutrition/migrations Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change 1
1
from django .db import migrations
2
2
3
+ from wger .utils .db import is_postgres_db
3
4
4
- class Migration (migrations .Migration ):
5
- dependencies = [
6
- ('nutrition' , '0024_remove_ingredient_status' ),
7
- ]
8
5
9
- operations = [
10
- migrations .RunSQL (
6
+ def add_publication (apps , schema_editor ):
7
+ if is_postgres_db ():
8
+ schema_editor .execute (
11
9
"""
12
10
DO $$
13
11
BEGIN
@@ -17,9 +15,20 @@ class Migration(migrations.Migration):
17
15
CREATE PUBLICATION powersync FOR ALL TABLES;
18
16
END IF;
19
17
END $$;
20
- """ ,
21
- reverse_sql = """
22
- DROP PUBLICATION IF EXISTS powersync;
23
- """ ,
24
- ),
18
+ """
19
+ )
20
+
21
+
22
+ def remove_publication (apps , schema_editor ):
23
+ if is_postgres_db ():
24
+ schema_editor .execute ('DROP PUBLICATION IF EXISTS powersync;' )
25
+
26
+
27
+ class Migration (migrations .Migration ):
28
+ dependencies = [
29
+ ('nutrition' , '0024_remove_ingredient_status' ),
30
+ ]
31
+
32
+ operations = [
33
+ migrations .RunPython (add_publication , reverse_code = remove_publication ),
25
34
]
You can’t perform that action at this time.
0 commit comments