diff --git a/spec/init_pg.sh b/spec/init_pg.sh deleted file mode 100644 index 6dd159bd6..000000000 --- a/spec/init_pg.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -USER = postgres -DB = "clear_spec" - -psql -U $USER -C "DROP IF EXISTS DATABASE $DB; CREATE DATABASE $DB;" -psql -U $USER -d $DB "CREATE TABLE users(id integer PRIMARY, first_name );" diff --git a/spec/migration/migration_spec.cr b/spec/migration/migration_spec.cr index 0ad2c60d7..902fd6650 100644 --- a/spec/migration/migration_spec.cr +++ b/spec/migration/migration_spec.cr @@ -70,4 +70,15 @@ module MigrationSpec end end end + + temporary do + describe "Migration" do + it "can run migrations apply_all multiple times" do + Clear::Migration::Manager.instance.reinit! + # Ensure that multiple migration apply_all's can run without issue + Clear::Migration::Manager.instance.apply_all + Clear::Migration::Manager.instance.apply_all + end + end + end end diff --git a/spec/model/model_spec.cr b/spec/model/model_spec.cr index 7738c0da6..1cb62c7b0 100644 --- a/spec/model/model_spec.cr +++ b/spec/model/model_spec.cr @@ -72,11 +72,11 @@ module ModelSpec end end - Clear::Migration::Manager.instance.reinit! - ModelSpecMigration123.new.apply(Clear::Migration::Direction::UP) + temporary do + Clear::Migration::Manager.instance.reinit! + ModelSpecMigration123.new.apply(Clear::Migration::Direction::UP) - describe "Clear::Model" do - temporary do + describe "Clear::Model" do context "fields management" do it "can load from array" do temporary do diff --git a/src/clear/migration/manager.cr b/src/clear/migration/manager.cr index 752812bd1..51dd21c1c 100644 --- a/src/clear/migration/manager.cr +++ b/src/clear/migration/manager.cr @@ -137,9 +137,12 @@ class Clear::Migration::Manager ensure_ready list_of_migrations = @migrations.sort { |a, b| a.uid <=> b.uid } - list_of_migrations.reject! { |x| @migrations_up.includes?(x) } + list_of_migrations.reject! { |x| @migrations_up.includes?(x.uid) } - list_of_migrations.each(&.apply(Clear::Migration::Direction::UP)) + list_of_migrations.each do |migration| + migration.apply(Clear::Migration::Direction::UP) + @migrations_up.add(migration.uid) + end end # diff --git a/src/clear/model/collection.cr b/src/clear/model/collection.cr index a22549d76..5dcd8e62d 100644 --- a/src/clear/model/collection.cr +++ b/src/clear/model/collection.cr @@ -161,7 +161,7 @@ module Clear::Model end def [](off) : T - self.[]?(off).not_nil + self.[]?(off).not_nil! end def []?(off) : T?