Skip to content

Commit

Permalink
Commande pour ré-initialiser les tables dagrun et dagrunchange (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolok authored Dec 4, 2024
1 parent aacbe86 commit c219fc4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/sync_databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
- name: Execute migrations in one-off container
run: |
scalingo --app ${PREPROD_APP} run python manage.py migrate
- name: Truncate the dagruns table
run: |
scalingo --app ${PREPROD_APP} run python manage.py reinitialize_dagrun
sync_prod_to_preprod_s3:
name: Copy Prod s3 bucket to Copy Preprod s3 bucket
Expand Down
15 changes: 15 additions & 0 deletions qfdmo/management/commands/reinitialize_dagrun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.core.management.base import BaseCommand
from django.db import connection


class Command(BaseCommand):
help = "Export Ressources using CSV format"

def handle(self, *args, **options):
with connection.cursor() as cursor:
# Truncate the table qfdmo_dagrun and qfdmo_dagrunchange
cursor.execute("TRUNCATE TABLE qfdmo_dagrun CASCADE")

# Set auto-increment to 1
cursor.execute("ALTER SEQUENCE qfdmo_dagrun_id_seq RESTART WITH 1")
cursor.execute("ALTER SEQUENCE qfdmo_dagrunchange_id_seq RESTART WITH 1")

0 comments on commit c219fc4

Please sign in to comment.