Files
redux-scraper/db/migrate/20230207211826_create_domain_fa_posts.rb
2025-01-01 03:29:53 +00:00

62 lines
1.7 KiB
Ruby

# typed: true
class CreateDomainFaPosts < ActiveRecord::Migration[7.0]
def up
create_table :domain_fa_posts do |t|
t.integer :fa_id
t.index :fa_id, unique: true
# ::Domain::Fa::User.id
t.references :creator
# just start with this for now - can add more fields later
t.string :title
t.string :category
t.string :theme
t.string :species
t.string :gender
t.string :description
t.jsonb :keywords
t.integer :num_favorites
t.integer :num_comments
t.integer :num_views
t.datetime :posted_at
# the primary file associated with the FA post
t.string :file_url_str
t.references :file
t.timestamps
end
# Fa::Post.file -> HttpLogEntry.id
add_foreign_key :domain_fa_posts,
:http_log_entries,
column: :file_id,
primary_key: :id,
validate: true
create_table :domain_fa_post_http_log_entry_joins do |t|
t.references :post, null: false
t.references :entry, null: false
t.jsonb :metadata
end
# Fa::PostHttpLogEntryJoin.post_id -> Fa::Post.id
add_foreign_key :domain_fa_post_http_log_entry_joins,
:domain_fa_posts,
column: :post_id,
primary_key: :id,
validate: true
# Fa::PostHttpLogEntryJoin.post_id -> HttpLogEntry.id
add_foreign_key :domain_fa_post_http_log_entry_joins,
:http_log_entries,
column: :entry_id,
primary_key: :id,
validate: true
end
def down
raise("boom")
end
end