Sha256: 125c4d3702004ee80662bd9409817f6c33cd2af9611e5ceff48d6de1e0c2d3d0

Contents?: true

Size: 1.33 KB

Versions: 38

Compression:

Stored size: 1.33 KB

Contents

require "spec_helper"

describe DataMigrate::LegacyMigrator do
  let(:context) {
    DataMigrate::MigrationContext.new("spec/db/data")
  }

  after do
    begin
      ActiveRecord::Migration.drop_table("data_migrations")
      ActiveRecord::Migration.drop_table("schema_migrations")
    rescue StandardError
      nil
    end
  end

  before do
    ActiveRecord::Base.establish_connection(db_config)
    ActiveRecord::SchemaMigration.create_table
    DataMigrate::DataSchemaMigration.create_table
  end

  let(:db_config) do
    {
      adapter: "sqlite3",
      database: "spec/db/test.db"
    }
  end

  it "migrate legacy migrations to be in correct table" do
    DataMigrate::DataSchemaMigration.create_table
    # simulate creation of legacy data migration when
    # it was recorded in schema table
    ActiveRecord::SchemaMigration.create(version: "20091231235959")

    # create one migration in correct place
    DataMigrate::DataSchemaMigration.create(version: "20171231235959")

    migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated
    expect(migrated.count).to eq 1

    DataMigrate::LegacyMigrator.new("spec/db/data").migrate

    # after migacy migrator has been run, we should have records
    # of both migrations
    migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated
    expect(migrated.count).to eq 2
  end

end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
data_migrate-9.0.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.5.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.4.2 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.4.1 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.4.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.3.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.2.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.1.1 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.1.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.0.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.0.0.rc2 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-8.0.0.rc1 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-7.0.2 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-7.0.1 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-7.0.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-6.8.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-6.7.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-6.6.2 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-6.6.0 spec/data_migrate/legacy_migrator_spec.rb
data_migrate-6.5.0 spec/data_migrate/legacy_migrator_spec.rb