automigration 0.2.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. data/.rspec +1 -0
  2. data/.travis.yml +1 -3
  3. data/CHANGELOG.md +13 -0
  4. data/README.md +44 -23
  5. data/Rakefile +10 -12
  6. data/automigration.gemspec +4 -0
  7. data/lib/automigration.rb +5 -38
  8. data/lib/automigration/active_record_ext.rb +17 -0
  9. data/lib/automigration/db_column.rb +32 -0
  10. data/lib/automigration/dsl.rb +29 -0
  11. data/lib/automigration/engine.rb +23 -0
  12. data/lib/automigration/field.rb +75 -0
  13. data/lib/automigration/fields_keeper.rb +85 -0
  14. data/lib/automigration/migrator.rb +38 -77
  15. data/lib/automigration/version.rb +1 -1
  16. data/spec/dummy/.gitignore +2 -0
  17. data/spec/dummy/README.rdoc +261 -0
  18. data/spec/dummy/Rakefile +7 -0
  19. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  20. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/{log → spec/dummy/app/mailers}/.gitkeep +0 -0
  24. data/spec/dummy/app/models/.gitkeep +0 -0
  25. data/spec/dummy/app/models/accessible_model.rb +6 -0
  26. data/spec/dummy/app/models/auto_migration1.rb +14 -0
  27. data/{test → spec/dummy/app}/models/auto_migration1a.rb +2 -2
  28. data/{test → spec/dummy/app}/models/auto_migration2.rb +2 -2
  29. data/spec/dummy/app/models/auto_migration3.rb +5 -0
  30. data/{test → spec/dummy/app}/models/belongs_to_model.rb +0 -0
  31. data/{test → spec/dummy/app}/models/boolean_model.rb +0 -0
  32. data/{test → spec/dummy/app}/models/form_field.rb +0 -0
  33. data/{test → spec/dummy/app}/models/form_field2.rb +1 -1
  34. data/{test → spec/dummy/app}/models/local_name.rb +0 -0
  35. data/{test → spec/dummy/app}/models/local_name2.rb +0 -0
  36. data/{test → spec/dummy/app}/models/not_automigrable.rb +0 -0
  37. data/{test → spec/dummy/app}/models/searchable.rb +0 -0
  38. data/{test → spec/dummy/app}/models/simple.rb +0 -0
  39. data/{test → spec/dummy/app}/models/user1.rb +0 -0
  40. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  41. data/spec/dummy/config.ru +4 -0
  42. data/spec/dummy/config/application.rb +56 -0
  43. data/spec/dummy/config/boot.rb +10 -0
  44. data/spec/dummy/config/database.yml +14 -0
  45. data/spec/dummy/config/environment.rb +5 -0
  46. data/spec/dummy/config/environments/development.rb +37 -0
  47. data/spec/dummy/config/environments/production.rb +67 -0
  48. data/spec/dummy/config/environments/test.rb +37 -0
  49. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  50. data/spec/dummy/config/initializers/inflections.rb +15 -0
  51. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  52. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  53. data/spec/dummy/config/initializers/session_store.rb +8 -0
  54. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  55. data/spec/dummy/config/locales/en.yml +5 -0
  56. data/spec/dummy/config/routes.rb +58 -0
  57. data/spec/dummy/db/.gitkeep +0 -0
  58. data/spec/dummy/lib/assets/.gitkeep +0 -0
  59. data/spec/dummy/log/.gitkeep +0 -0
  60. data/spec/dummy/public/404.html +26 -0
  61. data/spec/dummy/public/422.html +26 -0
  62. data/spec/dummy/public/500.html +25 -0
  63. data/spec/dummy/public/favicon.ico +0 -0
  64. data/spec/dummy/script/rails +6 -0
  65. data/spec/lib/accessible_spec.rb +13 -0
  66. data/spec/lib/auto_migration_spec.rb +155 -0
  67. data/spec/lib/belongs_to_spec.rb +38 -0
  68. data/spec/lib/db_column_spec.rb +21 -0
  69. data/spec/lib/fields_spec.rb +22 -0
  70. data/spec/spec_helper.rb +24 -0
  71. metadata +106 -47
  72. data/lib/automigration/base_extention.rb +0 -15
  73. data/lib/automigration/fields/belongs_to.rb +0 -29
  74. data/lib/automigration/fields/boolean.rb +0 -9
  75. data/lib/automigration/fields/date.rb +0 -9
  76. data/lib/automigration/fields/datetime.rb +0 -9
  77. data/lib/automigration/fields/float.rb +0 -9
  78. data/lib/automigration/fields/integer.rb +0 -9
  79. data/lib/automigration/fields/password.rb +0 -9
  80. data/lib/automigration/fields/string.rb +0 -9
  81. data/lib/automigration/fields/sys/base.rb +0 -95
  82. data/lib/automigration/fields/sys/db_column.rb +0 -36
  83. data/lib/automigration/fields/sys/keeper.rb +0 -113
  84. data/lib/automigration/fields/sys/slice_creater.rb +0 -32
  85. data/lib/automigration/fields/text.rb +0 -9
  86. data/lib/automigration/fields/time.rb +0 -9
  87. data/test/auto_migration_test.rb +0 -186
  88. data/test/belongs_to_test.rb +0 -51
  89. data/test/db_column_test.rb +0 -23
  90. data/test/fields/accessible_test.rb +0 -13
  91. data/test/fields_test.rb +0 -34
  92. data/test/models/accessible_model.rb +0 -6
  93. data/test/models/auto_migration1.rb +0 -14
  94. data/test/models/auto_migration3.rb +0 -5
  95. data/test/test_helper.rb +0 -35
@@ -1,15 +0,0 @@
1
- module ActiveRecord
2
- class Base
3
- class_attribute :__fields_keeper
4
- self.__fields_keeper = nil
5
-
6
- def self.fields_keeper
7
- self.__fields_keeper ||= ::Automigration::Fields::Sys::Keeper.new(self)
8
- end
9
-
10
- class << self
11
- delegate :has_fields, :add_field, :migration_attr, :to => :fields_keeper
12
- delegate :get_field, :get_field_safe, :get_fields, :to => :fields_keeper
13
- end
14
- end
15
- end
@@ -1,29 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class BelongsTo < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types(:type => :integer, :name => "#{@name}_id")]
6
- end
7
-
8
- def extend_model!(model)
9
- super
10
-
11
- model.belongs_to @name,
12
- :class_name => @options[:class_name],
13
- :inverse_of => @options[:inverse_of]
14
-
15
- if @options[:accessible]
16
- model.attr_accessible "#{@name}_id"
17
- end
18
- end
19
-
20
- def assert_options!
21
- raise "wrong name '#{@name}'" if @name =~ /_id$/
22
- end
23
-
24
- def valid_options_keys
25
- super + [:class_name, :inverse_of]
26
- end
27
- end
28
- end
29
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Boolean < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types(:default => !!@options[:default])]
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Date < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types]
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Datetime < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types]
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Float < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types]
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Integer < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types]
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Password < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types(:type => :string)]
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class String < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types]
6
- end
7
- end
8
- end
9
- end
@@ -1,95 +0,0 @@
1
- module Automigration
2
- module Fields
3
- module Sys
4
- class Base
5
- def self.all
6
- [
7
- Fields::BelongsTo,
8
- Fields::Boolean,
9
- Fields::Date,
10
- Fields::Datetime,
11
- Fields::Float,
12
- Fields::Integer,
13
- Fields::Password,
14
- Fields::String,
15
- Fields::Text,
16
- Fields::Time
17
- ]
18
- end
19
-
20
- attr_reader :options, :name
21
-
22
- def initialize(options)
23
- options.assert_valid_keys(valid_options_keys)
24
-
25
- @name = options[:name]
26
- @options = options.except(:name, :as).reverse_merge(:accessible => true)
27
-
28
- assert_options!
29
- end
30
-
31
- # overload these methods if needed [begin]
32
- def to_db_columns
33
- []
34
- end
35
-
36
- def valid_options_keys
37
- [
38
- :name, :as, # system attributes
39
- :default, :null, :limit, :scale, :precision, # db columns keys
40
- :accessible, # mark attribute as accessible
41
- :ru, :en, :de # languages
42
- ]
43
- end
44
-
45
- def assert_options!
46
- end
47
-
48
- def extend_model!(model)
49
- if @options[:accessible]
50
- model.attr_accessible @name
51
- end
52
- end
53
- # overload these methods if needed [end]
54
-
55
- def self.kind
56
- @kind ||= self.to_s.underscore.sub("automigration/fields/", '').to_sym
57
- end
58
-
59
- def self.from_meta(meta)
60
- all.each do |field_class|
61
- if field_class.kind == meta[:as]
62
- return field_class.new(meta)
63
- end
64
- end
65
- raise "wrong meta: #{meta.inspect}"
66
- end
67
-
68
- protected
69
- def db_column_for_standart_types(options = {})
70
- options.assert_valid_keys(:default, :null, :limit, :scale, :precision, :type, :name)
71
-
72
- if options[:type]
73
- type = options[:type]
74
- else
75
- type = self.class.kind
76
- end
77
-
78
- if options[:name]
79
- column_name = options[:name]
80
- else
81
- column_name = @name
82
- end
83
-
84
- DbColumn.new(column_name, type, options.except(:type, :name).reverse_merge({
85
- :default => @options[:default],
86
- :null => @options[:null],
87
- :limit => @options[:limit],
88
- :scale => @options[:scale],
89
- :precision => @options[:precision]
90
- }))
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,36 +0,0 @@
1
- module Automigration
2
- module Fields
3
- module Sys
4
- class DbColumn < Struct.new(:name, :type, :options)
5
- def initialize(name_, type_, options_)
6
- super
7
- options_.assert_valid_keys(:default, :null, :limit, :scale, :precision)
8
- end
9
-
10
- def self.from_activerecord_column(column)
11
- out = DbColumn.new(column.name.to_sym, column.type.to_sym, {
12
- :default => column.default,
13
- :null => column.null,
14
- :limit => column.limit,
15
- :scale => column.scale,
16
- :precision => column.precision
17
- })
18
- end
19
-
20
- def the_same?(other)
21
- (__to_array <=> other.send(:__to_array)) == 0
22
- end
23
-
24
- def to_options
25
- options.reject{|k, v| v.nil?}
26
- end
27
-
28
- private
29
- # compare only by 3 values
30
- def __to_array
31
- [name.to_s, type.to_s, options[:default].to_s]
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,113 +0,0 @@
1
- module Automigration
2
- module Fields
3
- module Sys
4
- class Keeper
5
- attr_reader :fields
6
- attr_reader :migration_attrs
7
-
8
- def initialize(model)
9
- @model = model
10
- @fields = nil
11
- @devise_fields = []
12
- @migration_attrs = []
13
- @timestamps_added = false
14
-
15
- @fields_lookup = {}
16
- end
17
-
18
- def has_fields(options = {}, &block)
19
- options.assert_valid_keys(:timestamps)
20
- options.reverse_merge!(:timestamps => true)
21
-
22
- slice_creater = SliceCreater.new
23
- yield slice_creater
24
-
25
- slice_creater.fields.each do |field|
26
- Fields::Sys::Base.from_meta(field).extend_model!(@model)
27
- end
28
-
29
- @fields ||= []
30
- @fields += slice_creater.fields
31
- @devise_fields = slice_creater.devise_fields
32
-
33
- if !@timestamps_added && options[:timestamps]
34
- @timestamps_added = true
35
- @fields << {:as => :datetime, :name => :created_at, :accessible => false}
36
- @fields << {:as => :datetime, :name => :updated_at, :accessible => false}
37
- end
38
- end
39
-
40
- def add_field(type, name, options = {})
41
- has_fields(:timestamps => false) do |f|
42
- f.send type, name, options
43
- end
44
- end
45
-
46
- def migration_attr(*args)
47
- @migration_attrs += args.flatten.map(&:to_s)
48
- end
49
-
50
- def auto_migrable?
51
- @fields.present?
52
- end
53
-
54
- def get_field(field_name)
55
- @fields_lookup[field_name] ||= begin
56
- meta = @fields.detect{|meta| meta[:name] == field_name}
57
- raise "wrong field_name: #{field_name}" unless meta
58
- Fields::Sys::Base.from_meta(meta)
59
- end
60
- end
61
-
62
- def get_field_safe(field_name)
63
- get_field(field_name)
64
- rescue RuntimeError
65
- end
66
-
67
- def get_fields
68
- @get_fields ||= @fields.map do |meta|
69
- get_field(meta[:name])
70
- end
71
- end
72
-
73
- def db_columns_for_field(field_name)
74
- meta = @fields.detect{|meta| meta[:name] == field_name}
75
- if meta
76
- Fields::Sys::Base.from_meta(meta).to_db_columns
77
- else
78
- []
79
- end
80
- end
81
-
82
- def db_columns
83
- out = []
84
-
85
- out += @fields.map do |meta|
86
- Fields::Sys::Base.from_meta(meta).to_db_columns
87
- end.flatten
88
-
89
- if defined?(Devise::Schema)
90
- devise_schema = Class.new do
91
- include Devise::Schema
92
-
93
- define_method :apply_devise_schema do |*args|
94
- opts = args.extract_options!
95
- raise "wrong arguments" unless args.size == 2
96
- name = args[0]
97
- as = args[1].to_s.underscore.to_sym
98
- as = :datetime if as == :date_time
99
- out << DbColumn.new(name, as, opts)
100
- end
101
- end.new
102
-
103
- @devise_fields.each do |meta|
104
- devise_schema.send(meta[:as].to_s.sub(/^devise_/, ''), *meta[:args])
105
- end
106
- end
107
-
108
- out
109
- end
110
- end
111
- end
112
- end
113
- end
@@ -1,32 +0,0 @@
1
- module Automigration
2
- module Fields
3
- module Sys
4
- class SliceCreater
5
- attr_reader :fields
6
- attr_reader :devise_fields
7
-
8
- def initialize
9
- @fields = []
10
- @devise_fields = []
11
- end
12
-
13
- Fields::Sys::Base.all.each do |field_class|
14
- define_method field_class.kind do |*args|
15
- options = args.extract_options!
16
- raise "wrong amount of args" unless args.size == 1
17
- name = args[0]
18
- @fields << {:name => name, :as => field_class.kind}.merge(options)
19
- end
20
- end
21
-
22
- def method_missing(meth, *args, &block)
23
- if meth.to_s =~ /^devise_(.*)/
24
- @devise_fields << {:as => meth, :args => args}
25
- else
26
- super
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Text < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types]
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Automigration
2
- module Fields
3
- class Time < Sys::Base
4
- def to_db_columns
5
- [db_column_for_standart_types]
6
- end
7
- end
8
- end
9
- end
@@ -1,186 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Automigration
4
- class AutoMigrationTest < ActiveSupport::TestCase
5
- def setup
6
- @migrations_path = Migrator.migrations_path
7
- @system_tables = Migrator.system_tables
8
- @models_to_ignore = Migrator.models_to_ignore
9
- end
10
-
11
- def teardown
12
- Migrator.set_migrations_path(@migrations_path)
13
- Migrator.set_system_tables(@system_tables)
14
- Migrator.set_models_to_ignore(@models_to_ignore)
15
-
16
- if connection.table_exists?('not_used_table')
17
- connection.drop_table('not_used_table')
18
- end
19
-
20
- if connection.table_exists?('schema_migrations')
21
- connection.drop_table('schema_migrations')
22
- end
23
-
24
- FileUtils.rm_rf(migrations_dir)
25
-
26
- connection.drop_table('auto_migration1s') if Migrator.all_tables.index('auto_migration1s')
27
- connection.drop_table('auto_migration2s')
28
- Migrator.new(:skip_output => true).update_schema!
29
- end
30
-
31
- def test_create_table_if_need
32
- connection.drop_table('auto_migration1s')
33
- assert !Migrator.all_tables.index('auto_migration1s')
34
-
35
- Migrator.new(:skip_output => true).update_schema!
36
- assert Migrator.all_tables.index('auto_migration1s')
37
- end
38
-
39
- def test_not_create_table_if_ignored
40
- connection.drop_table('auto_migration1s')
41
- assert !Migrator.all_tables.index('auto_migration1s')
42
-
43
- Migrator.set_models_to_ignore(['auto_migration1'])
44
- Migrator.new(:skip_output => true).update_schema!
45
- assert !Migrator.all_tables.index('auto_migration1s')
46
- end
47
-
48
- def test_remove_unused_table
49
- connection.create_table('not_used_table')
50
- assert Migrator.all_tables.index('not_used_table')
51
-
52
- Migrator.new(:skip_output => true).update_schema!
53
- assert !Migrator.all_tables.index('not_used_table')
54
- end
55
-
56
- def test_not_remove_unused_table_if_it_checked_as_not_migratable
57
- connection.create_table('not_used_table')
58
- Migrator.set_system_tables(%w(not_used_table))
59
- assert Migrator.all_tables.index('not_used_table')
60
-
61
- Migrator.new(:skip_output => true).update_schema!
62
- assert Migrator.all_tables.index('not_used_table')
63
- end
64
-
65
- def test_clean_unused_migration
66
- connection.create_table('schema_migrations') do |t|
67
- t.string :version
68
- end
69
- connection.execute("INSERT INTO schema_migrations(version) VALUES('20110114120000')")
70
- connection.execute("INSERT INTO schema_migrations(version) VALUES('20110114132500')")
71
- connection.execute("INSERT INTO schema_migrations(version) VALUES('20110114193000')")
72
-
73
- FileUtils.mkdir_p(migrations_dir)
74
- File.open(migrations_dir + "/20110114120000_create_users.rb", "w"){|f| f.puts "# some text"}
75
- File.open(migrations_dir + "/20110114193000_create_projects.rb", "w"){|f| f.puts "# some text"}
76
-
77
- Migrator.set_migrations_path(migrations_dir)
78
-
79
- count_sql = "SELECT count(*) AS count FROM schema_migrations"
80
- assert_equal 3, connection.execute(count_sql)[0]['count'].to_i
81
- Migrator.new(:skip_output => true).update_schema!
82
- assert_equal 2, connection.execute(count_sql)[0]['count'].to_i
83
- end
84
-
85
- def test_update_column_for_model_not_change_type_dramatically
86
- connection.remove_column(AutoMigration1.table_name, 'string_field')
87
- connection.add_column(AutoMigration1.table_name, 'string_field', :integer)
88
- AutoMigration1.reset_column_information
89
-
90
- AutoMigration1.create!(:string_field => 123)
91
- assert_equal 123, AutoMigration1.first.string_field
92
-
93
- Migrator.new(:skip_output => true).update_schema!
94
-
95
- assert_equal '123', AutoMigration1.first.string_field
96
- end
97
-
98
- def test_update_column_for_model_change_type_dramatically
99
- connection.remove_column(AutoMigration1.table_name, 'integer_field')
100
- connection.add_column(AutoMigration1.table_name, 'integer_field', :string)
101
- AutoMigration1.reset_column_information
102
-
103
- AutoMigration1.create!(:integer_field => 'abc')
104
- assert_equal 'abc', AutoMigration1.first.integer_field
105
-
106
- Migrator.new(:skip_output => true).update_schema!
107
-
108
- assert_equal nil, AutoMigration1.first.integer_field
109
- end
110
-
111
- def test_create_columns_for_model
112
- assert AutoMigration1.new.attributes.keys.index("boolean_field")
113
- assert AutoMigration1.new.attributes.keys.index("integer_field")
114
- assert AutoMigration1.new.attributes.keys.index("float_field")
115
- assert AutoMigration1.new.attributes.keys.index("string_field")
116
- assert AutoMigration1.new.attributes.keys.index("text_field")
117
- assert AutoMigration1.new.attributes.keys.index("datetime_field")
118
- assert AutoMigration1.new.attributes.keys.index("date_field")
119
- assert AutoMigration1.new.attributes.keys.index("time_field")
120
- assert AutoMigration1.new.attributes.keys.index("additional_field")
121
-
122
- assert AutoMigration1.new.attributes.keys.index("created_at")
123
- assert AutoMigration1.new.attributes.keys.index("updated_at")
124
- end
125
-
126
- def test_create_columns_for_model_add_field
127
- assert AutoMigration1a.new.attributes.keys.index("additional_field")
128
- assert AutoMigration1a.new.attributes.keys.index("integer_field")
129
-
130
- assert AutoMigration1a.new.attributes.keys.index("created_at")
131
- assert AutoMigration1a.new.attributes.keys.index("updated_at")
132
- end
133
-
134
- def test_create_model_without_timestamps
135
- assert !AutoMigration3.new.attributes.keys.index("created_at")
136
- assert !AutoMigration3.new.attributes.keys.index("updated_at")
137
- end
138
-
139
- def test_destroy_columns_for_model
140
- connection.add_column(AutoMigration1.table_name, 'new_column', :string)
141
- AutoMigration1.reset_column_information
142
-
143
- assert AutoMigration1.column_names.index('new_column')
144
- Migrator.new(:skip_output => true).update_schema!
145
- assert !AutoMigration1.column_names.index('new_column')
146
- end
147
-
148
- def test_destroy_columns_for_model
149
- connection.add_column(AutoMigration1.table_name, 'new_column', :string)
150
- AutoMigration1.reset_column_information
151
-
152
- assert AutoMigration1.column_names.index('new_column')
153
- Migrator.new(:skip_output => true).update_schema!
154
- assert !AutoMigration1.column_names.index('new_column')
155
- end
156
-
157
- def test_destroy_columns_for_model_if_they_are_not_migrate_attr
158
- connection.add_column(AutoMigration2.table_name, 'some_attr1', :string)
159
- connection.add_column(AutoMigration2.table_name, 'some_attr2', :string)
160
- connection.add_column(AutoMigration2.table_name, 'some_attr3', :string)
161
- connection.add_column(AutoMigration2.table_name, 'some_attr4', :string)
162
- AutoMigration2.reset_column_information
163
-
164
- assert AutoMigration2.column_names.index('some_attr1')
165
- assert AutoMigration2.column_names.index('some_attr2')
166
- assert AutoMigration2.column_names.index('some_attr3')
167
- assert AutoMigration2.column_names.index('some_attr4')
168
-
169
- Migrator.new(:skip_output => true).update_schema!
170
-
171
- assert AutoMigration2.column_names.index('some_attr1')
172
- assert AutoMigration2.column_names.index('some_attr2')
173
- assert AutoMigration2.column_names.index('some_attr3')
174
- assert !AutoMigration2.column_names.index('some_attr4')
175
- end
176
-
177
- private
178
- def migrations_dir
179
- File.expand_path("../../../tmp/migrations", __FILE__)
180
- end
181
-
182
- def connection
183
- ActiveRecord::Base.connection
184
- end
185
- end
186
- end