From 2174b21bda95431ca9d00671c649f5b4ce631bf1 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 11 Jan 2018 11:09:30 +1100 Subject: [PATCH] chore: improve table dropping code --- script/seed-matrix.rb | 1 + tasks/database.rb | 1 + tasks/database/table_dependency_calculator.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/script/seed-matrix.rb b/script/seed-matrix.rb index 8136d3277..a4e99f204 100755 --- a/script/seed-matrix.rb +++ b/script/seed-matrix.rb @@ -4,6 +4,7 @@ $LOAD_PATH.unshift './lib' $LOAD_PATH.unshift './spec' +$LOAD_PATH.unshift './tasks' ENV['RACK_ENV'] = 'development' require 'sequel' require 'logger' diff --git a/tasks/database.rb b/tasks/database.rb index 69d7ecf3d..0ec4bb76d 100644 --- a/tasks/database.rb +++ b/tasks/database.rb @@ -40,6 +40,7 @@ def drop_tables ordered_tables.each do | table_name | database.drop_table(table_name, cascade: psql?) end + database.drop_table(:schema_migrations) end def drop_views diff --git a/tasks/database/table_dependency_calculator.rb b/tasks/database/table_dependency_calculator.rb index 465f07fff..9ea8f6be9 100644 --- a/tasks/database/table_dependency_calculator.rb +++ b/tasks/database/table_dependency_calculator.rb @@ -20,7 +20,7 @@ def call .collect{|it| @connection.foreign_key_list(it) .collect{|fk| {from: it, to: fk[:table]} } } .flatten - .uniq + .uniq - [:schema_migrations] check(@connection.tables, dependencies, ordered_table_names) ordered_table_names end