mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Don't truncate the schema_migrations table
This commit is contained in:
parent
8d7f72ffc9
commit
04c263e48c
5 changed files with 45 additions and 0 deletions
1
.ruby-gemset
Normal file
1
.ruby-gemset
Normal file
|
@ -0,0 +1 @@
|
|||
database_cleaner
|
|
@ -6,6 +6,15 @@ require 'database_cleaner/active_record/truncation/shared_fast_truncation'
|
|||
|
||||
module ActiveRecord
|
||||
module ConnectionAdapters
|
||||
describe "schema_migrations table" do
|
||||
it "is not truncated" do
|
||||
active_record_gp_migrate
|
||||
DatabaseCleaner::ActiveRecord::Truncation.new.clean
|
||||
result = active_record_pg_connection.execute("select count(*) from schema_migrations;")
|
||||
result.values.first.should eq ["2"]
|
||||
end
|
||||
end
|
||||
|
||||
describe do
|
||||
before(:all) { active_record_pg_setup }
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class CreateUsers < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :users do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :users
|
||||
end
|
||||
end
|
||||
|
||||
class ::User < ActiveRecord::Base
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
class CreateAgents < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :agents do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :agents
|
||||
end
|
||||
end
|
||||
|
||||
class ::Agent < ActiveRecord::Base
|
||||
end
|
|
@ -31,6 +31,13 @@ module PostgreSQLHelper
|
|||
load_schema
|
||||
end
|
||||
|
||||
def active_record_gp_migrate
|
||||
`dropdb #{config['database']}`
|
||||
create_db
|
||||
establish_connection
|
||||
ActiveRecord::Migrator.migrate 'spec/support/active_record/migrations'
|
||||
end
|
||||
|
||||
def active_record_pg_connection
|
||||
ActiveRecord::Base.connection
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue