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 4657cadc38..1f36175550 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 @@ -13,7 +13,7 @@ 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.integer :position, null: true, default: :null 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 diff --git a/ruby_event_store-active_record/spec/migration_test_spec.rb b/ruby_event_store-active_record/spec/migration_test_spec.rb index 5f61855cb8..d18bf52541 100644 --- a/ruby_event_store-active_record/spec/migration_test_spec.rb +++ b/ruby_event_store-active_record/spec/migration_test_spec.rb @@ -132,7 +132,7 @@ module ActiveRecord expect( sqlite_schema("event_store_events_in_streams") ).to eq <<~SCHEMA.strip - CREATE TABLE "event_store_events_in_streams" ("id" integer NOT NULL PRIMARY KEY, "stream" varchar NOT NULL, "position" integer DEFAULT NULL, "event_id" varchar(36) NOT NULL, "created_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_c8d52b5857" + CREATE TABLE "event_store_events_in_streams" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "stream" varchar NOT NULL, "position" integer DEFAULT NULL, "event_id" varchar(36) NOT NULL, "created_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_c8d52b5857" FOREIGN KEY ("event_id") REFERENCES "event_store_events" ("event_id") )