Drop types_de_piece_justificative
and pieces_justificatives
tables
Now that the content of these tables has been migrated, we can drop them.
This commit is contained in:
parent
95af8560b2
commit
befee0ea57
2 changed files with 41 additions and 27 deletions
|
@ -0,0 +1,40 @@
|
|||
class DropDeprecatedPieceJustificativeTables < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
assert_empty_table!(:types_de_piece_justificative)
|
||||
assert_empty_table!(:pieces_justificatives)
|
||||
|
||||
drop_table :types_de_piece_justificative do |t|
|
||||
t.string "libelle"
|
||||
t.string "description"
|
||||
t.boolean "api_entreprise", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "procedure_id"
|
||||
t.integer "order_place"
|
||||
t.string "lien_demarche"
|
||||
t.boolean "mandatory", default: false
|
||||
t.index ["procedure_id"], name: "index_types_de_piece_justificative_on_procedure_id"
|
||||
end
|
||||
|
||||
drop_table :pieces_justificatives do |t|
|
||||
t.string "content"
|
||||
t.integer "dossier_id"
|
||||
t.integer "type_de_piece_justificative_id"
|
||||
t.datetime "created_at"
|
||||
t.integer "user_id"
|
||||
t.string "original_filename"
|
||||
t.string "content_secure_token"
|
||||
t.datetime "updated_at"
|
||||
t.index ["dossier_id"], name: "index_pieces_justificatives_on_dossier_id"
|
||||
t.index ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id"
|
||||
end
|
||||
end
|
||||
|
||||
def assert_empty_table!(table)
|
||||
results = ActiveRecord::Base.connection.exec_query("SELECT COUNT(*) FROM #{table}")
|
||||
records_count = results.first['count']
|
||||
if records_count > 0
|
||||
raise "Abord dropping `#{table}` table: it still contains #{records_count} records."
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue