Skip to content

Commit

Permalink
Declare foreign_key via references
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlyobvious committed Mar 29, 2024
1 parent bfa95ec commit 96f8578
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
create_table(:event_store_events_in_streams, force: false) do |t|
t.string :stream, null: false
t.integer :position, null: true
t.references :event, null: false, type: :string, limit: 36, index: true
t.references :event, null: false, type: :string, limit: 36, index: true, foreign_key: { to_table: :event_store_events, primary_key: :event_id }
t.datetime :created_at, null: false, precision: 6, index: true

t.index [:stream, :position], unique: true
t.index [:stream, :event_id], unique: true
end

add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
create_table(:event_store_events_in_streams, force: false) do |t|
t.string :stream, null: false
t.integer :position, null: true
t.references :event, null: false, type: :string, limit: 36, index: true
t.references :event, null: false, type: :string, limit: 36, index: true, foreign_key: { to_table: :event_store_events, primary_key: :event_id }
t.datetime :created_at, null: false, precision: 6, index: true

t.index [:stream, :position], unique: true
t.index [:stream, :event_id], unique: true
end

add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
create_table(:event_store_events_in_streams, id: :bigserial, force: false) do |t|
t.string :stream, null: false
t.integer :position, null: true
t.references :event, null: false, type: :uuid, index: true
t.references :event, null: false, type: :uuid, index: true, foreign_key: { to_table: :event_store_events, primary_key: :event_id }
t.datetime :created_at, null: false, type: :timestamp, precision: 6, index: true

t.index [:stream, :position], unique: true
t.index [:stream, :event_id], unique: true
end

add_foreign_key "event_store_events_in_streams", "event_store_events", column: "event_id", primary_key: "event_id"
end
end

0 comments on commit 96f8578

Please sign in to comment.