Skip to content

Commit

Permalink
api/migrations/prod-data: delete code to truncate database
Browse files Browse the repository at this point in the history
We never want to delete the data in prod.
And if we want to, we can copy the code from the dev-data directory.
  • Loading branch information
BacLuc committed Aug 6, 2023
1 parent f9f90d1 commit 0b8bfef
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
1 change: 0 additions & 1 deletion api/migrations/prod-data/Version202210081114PM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 0 additions & 19 deletions api/migrations/prod-data/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0b8bfef

Please sign in to comment.