Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

add migration to create postgresql publication

Dieter Plaetinck71fc1c6a82ac
diff --git a/wger/nutrition/migrations/0025_create_publication.py b/wger/nutrition/migrations/0025_create_publication.py
new file mode 100644
index 000000000..c0f818c0e
--- /dev/null
+++ b/wger/nutrition/migrations/0025_create_publication.py
@@ -0,0 +1,26 @@
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('nutrition', '0024_remove_ingredient_status'),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ """
+ DO $$
+ BEGIN
+ IF NOT EXISTS (
+ SELECT 1 FROM pg_publication WHERE pubname = 'powersync'
+ ) THEN
+ CREATE PUBLICATION powersync FOR TABLE nutrition_ingredient, auth_user;
+ END IF;
+ END $$;
+ """,
+ reverse_sql="""
+ DROP PUBLICATION IF EXISTS powersync;
+ """
+ ),
+ ]