From 8cabfb70b6aa0201be00287721dad64eac4f4183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pacana?= Date: Fri, 29 Mar 2024 17:41:25 +0100 Subject: [PATCH] First event_store_events, then event_store_events_in_streams Tiny change, big consequences for the AR migration DSL. --- .../create_event_store_events_template.erb | 18 +++++++++--------- .../create_event_store_events_template.erb | 18 +++++++++--------- .../create_event_store_events_template.erb | 18 +++++++++--------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/create_event_store_events_template.erb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/create_event_store_events_template.erb index 5bcb07068e..33fa45e2bd 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/create_event_store_events_template.erb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/create_event_store_events_template.erb @@ -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 @@ -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 diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/mysql/create_event_store_events_template.erb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/mysql/create_event_store_events_template.erb index 5bd303c070..e7e8bf1a84 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/mysql/create_event_store_events_template.erb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/mysql/create_event_store_events_template.erb @@ -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 @@ -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 diff --git a/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/postgres/create_event_store_events_template.erb b/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/postgres/create_event_store_events_template.erb index e51686b7d4..2c59644f00 100644 --- a/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/postgres/create_event_store_events_template.erb +++ b/ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/templates/postgres/create_event_store_events_template.erb @@ -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 @@ -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