Class: CreateArchiveStorageFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/archive_storage/templates/create_archive_storage_files.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/archive_storage/templates/create_archive_storage_files.rb', line 4

def change
  create_table :archive_storage_files do |t|
    t.string :record_type, null: false
    t.bigint :record_id, null: false
    t.string :mounted_as, null: false
    t.string :uploader, null: false

    t.string :identifier, null: false
    t.string :storage_key, null: false
    t.string :source_storage_key
    t.string :target_storage_key

    t.string :current_storage, null: false
    t.string :source_storage
    t.string :target_storage

    t.bigint :byte_size
    t.string :checksum
    t.string :content_type

    t.datetime :migration_started_at
    t.datetime :enqueued_at
    t.datetime :migrated_at
    t.datetime :verified_at
    t.datetime :source_deleted_at

    t.boolean :source_delete_pending, null: false, default: false
    t.string :last_error
    t.integer :attempts, null: false, default: 0

    t.timestamps
  end

  add_index :archive_storage_files,
            [:record_type, :record_id, :mounted_as, :identifier],
            name: "idx_archive_storage_identity"

  add_index :archive_storage_files,
            [:uploader, :current_storage],
            name: "idx_archive_storage_uploader_storage"

  add_index :archive_storage_files,
            [:source_storage, :source_deleted_at],
            name: "idx_archive_storage_cleanup"

  add_index :archive_storage_files,
            [:source_delete_pending, :source_deleted_at],
            name: "idx_archive_storage_delete_pending"
end