From 7683c45ce16278b9bab5766537f1be6e6855b7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pacana?= Date: Fri, 29 Mar 2024 18:24:27 +0100 Subject: [PATCH] Mysterious ways of migration DSL translation on sqlite AUTOINCREMENT over plain ROWID is desired for a column that participates in ordering: https://www.sqlite.org/autoinc.html Added default just to match previous output, does not seem really needed. --- .../generators/templates/create_event_store_events_template.erb | 2 +- ruby_event_store-active_record/spec/migration_test_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 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 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") )