# typed: false
class CreateDomainE621Posts < ActiveRecord::Migration[7.0]
  def up
    create_table :domain_e621_posts do |t|
      t.integer :e621_id, null: false
      t.integer :state, null: false
      t.jsonb :state_detail

      t.string :md5
      t.string :file_url_str
      t.string :description
      t.integer :rating
      t.integer :score
      t.integer :score_up
      t.integer :score_down
      t.integer :num_favorites
      t.integer :num_comments
      t.integer :change_seq

      t.jsonb :flags_array
      t.jsonb :pools_array
      t.jsonb :sources_array
      t.jsonb :artists_array
      t.jsonb :tags_array

      t.references :file
      t.references :parent_e621

      t.datetime :deleted_at
      t.timestamps

      t.index :e621_id, unique: :true
      t.index :md5, where: "deleted_at is null", unique: :true
    end

    create_versions_table :domain_e621_posts
  end

  def down
    raise("boom!")
  end
end
