Files
ubicloud/migrate/20230727_soft_delete_models.rb
Burak Yucesoy 0cab29c98f Archive deleted records to a separate table
This is prerequisite for audit records. We should be able to identify which VMs
and IP addresses used by which Projects/Accounts at a given time, so that we
can take necessary precautions against network abuse and spamming.

Since keeping historical records are useful for debugging as well, with this
commit we enable soft delete for not only VMs/IP addresses but for almost all
other models too. There are two exceptions at the moment;
- DeletedRecord: Not archived to prevent infinite loops, also archiving them
is not very meaningful.
- Semaphore: Not archived because we produce a lot of them.

Of course keeping historical records makes GDPR compliance a bit more difficult,
but that can be resolved by deleting very old records via batch processing after
certain duration.
2023-08-01 11:58:57 +03:00

13 lines
399 B
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
create_table(:deleted_record) do
column :id, :uuid, primary_key: true, default: Sequel.lit("gen_random_uuid()")
column :deleted_at, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
column :model_name, :text, null: false
column :model_values, :jsonb, null: false, default: "{}"
end
end
end