Skip to content

Commit

Permalink
First event_store_events, then event_store_events_in_streams
Browse files Browse the repository at this point in the history
Tiny change, big consequences for the AR migration DSL.
  • Loading branch information
mostlyobvious committed Mar 29, 2024
1 parent 810b61a commit 8cabfb7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
def change
create_table(:event_store_events, force: false) do |t|
t.references :event, null: false, type: :string, limit: 36, index: { unique: true }
t.string :event_type, null: false, index: true
t.binary :metadata
t.binary :data, null: false
t.datetime :created_at, null: false, precision: 6, index: true
t.datetime :valid_at, null: true, precision: 6, index: true
end

create_table(:event_store_events_in_streams, force: false) do |t|
t.string :stream, null: false
t.integer :position, null: true
Expand All @@ -12,15 +21,6 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
add_index :event_store_events_in_streams, [:stream, :event_id], unique: true
add_index :event_store_events_in_streams, [:event_id]

create_table(:event_store_events, force: false) do |t|
t.references :event, null: false, type: :string, limit: 36, index: { unique: true }
t.string :event_type, null: false, index: true
t.binary :metadata
t.binary :data, null: false
t.datetime :created_at, null: false, precision: 6, index: true
t.datetime :valid_at, null: true, precision: 6, index: 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 @@ -2,6 +2,15 @@

class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
def change
create_table(:event_store_events, force: false) do |t|
t.references :event, null: false, type: :string, limit: 36, index: { unique: true }
t.string :event_type, null: false, index: true
t.<%= data_type %> :metadata
t.<%= data_type %> :data, null: false
t.datetime :created_at, null: false, precision: 6, index: true
t.datetime :valid_at, null: true, precision: 6, index: true
end

create_table(:event_store_events_in_streams, force: false) do |t|
t.string :stream, null: false
t.integer :position, null: true
Expand All @@ -12,15 +21,6 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
add_index :event_store_events_in_streams, [:stream, :event_id], unique: true
add_index :event_store_events_in_streams, [:event_id]

create_table(:event_store_events, force: false) do |t|
t.references :event, null: false, type: :string, limit: 36, index: { unique: true }
t.string :event_type, null: false, index: true
t.<%= data_type %> :metadata
t.<%= data_type %> :data, null: false
t.datetime :created_at, null: false, precision: 6, index: true
t.datetime :valid_at, null: true, precision: 6, index: 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 @@ -2,6 +2,15 @@

class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
def change
create_table(:event_store_events, id: :bigserial, force: false) do |t|
t.references :event, null: false, type: :uuid, index: { unique: true }
t.string :event_type, null: false, index: true
t.<%= data_type %> :metadata
t.<%= data_type %> :data, null: false
t.datetime :created_at, null: false, type: :timestamp, precision: 6, index: true
t.datetime :valid_at, null: true, type: :timestamp, precision: 6, index: true
end

create_table(:event_store_events_in_streams, id: :bigserial, force: false) do |t|
t.string :stream, null: false
t.integer :position, null: true
Expand All @@ -12,15 +21,6 @@ class CreateEventStoreEvents < ActiveRecord::Migration[<%= migration_version %>]
add_index :event_store_events_in_streams, [:stream, :event_id], unique: true
add_index :event_store_events_in_streams, [:event_id]

create_table(:event_store_events, id: :bigserial, force: false) do |t|
t.references :event, null: false, type: :uuid, index: { unique: true }
t.string :event_type, null: false, index: true
t.<%= data_type %> :metadata
t.<%= data_type %> :data, null: false
t.datetime :created_at, null: false, type: :timestamp, precision: 6, index: true
t.datetime :valid_at, null: true, type: :timestamp, precision: 6, index: 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 8cabfb7

Please sign in to comment.