Skip to content

Instantly share code, notes, and snippets.

@thegorgon
Created June 2, 2023 18:24
Show Gist options
  • Save thegorgon/afcc36859497e2b2da38e1e85fe03827 to your computer and use it in GitHub Desktop.
Save thegorgon/afcc36859497e2b2da38e1e85fe03827 to your computer and use it in GitHub Desktop.
Table Options?
create_table :relationships do |t|
t.belongs_to :entity_left, polymorphic: true
t.belongs_to :entity_right, polymorphic: true
t.string :relationship_type
t.string :relationship_type_other
t.integer :ownership_percentage # For beneficial ownership
t.boolean :relationship_continues # For institution relationships
t.date :actioned_at # For institution relationships
t.string :status # For institution relationships
t.jsonb :other_metadata # For other relationships
end
# OR
create_table :relationships do |t|
t.belongs_to :entity_left, polymorphic: true
t.belongs_to :entity_right, polymorphic: true
t.string :relationship_type
t.string :relationship_type_other
t.jsonb :other_metadata
end
create_table :ownership_relationship_metadata do |t|
t.belongs_to :relationship
t.integer :ownership_percentage # For beneficial ownership
end
create_table :institution_relationship_metadata do |t|
t.belongs_to :relationship
t.boolean :relationship_continues # For institution relationships
t.date :actioned_at # For institution relationships
t.string :status # For institution relationships
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment