From 0b8bfef52084255e49e1feec808a63075daf0e16 Mon Sep 17 00:00:00 2001 From: BacLuc Date: Sun, 6 Aug 2023 11:27:20 +0200 Subject: [PATCH] api/migrations/prod-data: delete code to truncate database We never want to delete the data in prod. And if we want to, we can copy the code from the dev-data directory. --- .../prod-data/Version202210081114PM.php | 1 - api/migrations/prod-data/helpers.php | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/api/migrations/prod-data/Version202210081114PM.php b/api/migrations/prod-data/Version202210081114PM.php index 117201b5e6..ea34ddedca 100644 --- a/api/migrations/prod-data/Version202210081114PM.php +++ b/api/migrations/prod-data/Version202210081114PM.php @@ -16,7 +16,6 @@ public function getDescription(): string { public function up(Schema $schema): void { // START PHP CODE - // $this->addSql(createTruncateDatabaseCommand()); $statements = getStatementsForMigrationFile(); foreach ($statements as $statement) { diff --git a/api/migrations/prod-data/helpers.php b/api/migrations/prod-data/helpers.php index 7c3ad5ffed..a155d5d0c9 100644 --- a/api/migrations/prod-data/helpers.php +++ b/api/migrations/prod-data/helpers.php @@ -5,25 +5,6 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Statements\InsertStatement; -function createTruncateDatabaseCommand(): string { - return " - DO $$ DECLARE - r RECORD; - BEGIN - FOR r IN ( - SELECT tablename - FROM pg_tables - WHERE - schemaname = current_schema() - AND tablename != 'doctrine_migration_versions' - AND tablename != 'content_type') - LOOP - EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE'; - END LOOP; - END $$; - "; -} - function getStatementsForMigrationFile(): array { $dump_file = __DIR__.'/data.sql'; $sql = file_get_contents($dump_file);