schema_plus 0.4.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gitignore +3 -1
  2. data/.travis.yml +6 -9
  3. data/Gemfile +0 -4
  4. data/README.rdoc +168 -70
  5. data/Rakefile +58 -47
  6. data/gemfiles/rails-3.2/Gemfile.base +4 -0
  7. data/gemfiles/rails-3.2/Gemfile.mysql +4 -0
  8. data/gemfiles/rails-3.2/Gemfile.mysql2 +4 -0
  9. data/gemfiles/rails-3.2/Gemfile.postgresql +4 -0
  10. data/gemfiles/rails-3.2/Gemfile.sqlite3 +4 -0
  11. data/lib/schema_plus.rb +2 -0
  12. data/lib/schema_plus/active_record/column_options_handler.rb +73 -32
  13. data/lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb +60 -31
  14. data/lib/schema_plus/active_record/connection_adapters/foreign_key_definition.rb +7 -2
  15. data/lib/schema_plus/active_record/connection_adapters/index_definition.rb +2 -1
  16. data/lib/schema_plus/active_record/connection_adapters/mysql_adapter.rb +19 -1
  17. data/lib/schema_plus/active_record/connection_adapters/postgresql_adapter.rb +68 -17
  18. data/lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb +28 -3
  19. data/lib/schema_plus/active_record/connection_adapters/table_definition.rb +27 -1
  20. data/lib/schema_plus/active_record/db_default.rb +19 -0
  21. data/lib/schema_plus/active_record/foreign_keys.rb +40 -32
  22. data/lib/schema_plus/active_record/schema_dumper.rb +7 -3
  23. data/lib/schema_plus/version.rb +1 -1
  24. data/runspecs +5 -8
  25. data/schema_plus.gemspec +2 -5
  26. data/spec/column_definition_spec.rb +18 -1
  27. data/spec/column_spec.rb +39 -2
  28. data/spec/connection_spec.rb +1 -1
  29. data/spec/connections/mysql/connection.rb +1 -1
  30. data/spec/connections/mysql2/connection.rb +1 -1
  31. data/spec/connections/postgresql/connection.rb +1 -1
  32. data/spec/foreign_key_definition_spec.rb +0 -4
  33. data/spec/foreign_key_spec.rb +37 -13
  34. data/spec/index_definition_spec.rb +54 -2
  35. data/spec/index_spec.rb +59 -15
  36. data/spec/migration_spec.rb +336 -85
  37. data/spec/multiple_schemas_spec.rb +127 -0
  38. data/spec/schema_dumper_spec.rb +65 -25
  39. data/spec/schema_spec.rb +16 -18
  40. data/spec/spec_helper.rb +19 -18
  41. data/spec/support/matchers/reference.rb +7 -1
  42. data/spec/views_spec.rb +5 -2
  43. metadata +43 -54
  44. data/gemfiles/Gemfile.rails-2.3 +0 -6
  45. data/gemfiles/Gemfile.rails-2.3.lock +0 -65
  46. data/gemfiles/Gemfile.rails-3.0 +0 -5
  47. data/gemfiles/Gemfile.rails-3.0.lock +0 -113
  48. data/gemfiles/Gemfile.rails-3.1 +0 -5
  49. data/gemfiles/Gemfile.rails-3.1.lock +0 -123
  50. data/gemfiles/Gemfile.rails-3.2 +0 -5
  51. data/gemfiles/Gemfile.rails-3.2.lock +0 -121
  52. data/spec/models/comment.rb +0 -2
  53. data/spec/models/post.rb +0 -2
  54. data/spec/models/user.rb +0 -2
  55. data/spec/rails3_migration_spec.rb +0 -144
@@ -16,6 +16,30 @@ module SchemaPlus
16
16
 
17
17
  # :enddoc:
18
18
 
19
+ def self.included(base)
20
+ base.class_eval do
21
+ alias_method_chain :indexes, :schema_plus
22
+ alias_method_chain :rename_table, :schema_plus
23
+ end
24
+ end
25
+
26
+ def indexes_with_schema_plus(table_name, name = nil)
27
+ indexes = indexes_without_schema_plus(table_name, name)
28
+ exec_query("SELECT name, sql FROM sqlite_master WHERE type = 'index'").map do |row|
29
+ if (desc_columns = row['sql'].scan(/['"`]?(\w+)['"`]? DESC\b/).flatten).any?
30
+ index = indexes.detect{ |i| i.name == row['name'] }
31
+ index.orders = Hash[index.columns.map {|column| [column, desc_columns.include?(column) ? :desc : :asc]}]
32
+ end
33
+ end
34
+ indexes
35
+ end
36
+
37
+ def rename_table_with_schema_plus(oldname, newname) #:nodoc:
38
+ rename_table_without_schema_plus(oldname, newname)
39
+ rename_indexes_and_foreign_keys(oldname, newname)
40
+ end
41
+
42
+
19
43
  def add_foreign_key(table_name, column_names, references_table_name, references_column_names, options = {})
20
44
  raise NotImplementedError, "Sqlite3 does not support altering a table to add foreign key constraints (table #{table_name.inspect} column #{column_names.inspect})"
21
45
  end
@@ -54,7 +78,8 @@ module SchemaPlus
54
78
  SQL
55
79
 
56
80
  re = %r[
57
- \bFOREIGN\s+KEY\s* \(\s*[`"](.+?)[`"]\s*\)
81
+ \b(CONSTRAINT\s+(\S+)\s+)?
82
+ FOREIGN\s+KEY\s* \(\s*[`"](.+?)[`"]\s*\)
58
83
  \s*REFERENCES\s*[`"](.+?)[`"]\s*\((.+?)\)
59
84
  (\s+ON\s+UPDATE\s+(.+?))?
60
85
  (\s*ON\s+DELETE\s+(.+?))?
@@ -64,13 +89,13 @@ module SchemaPlus
64
89
  foreign_keys = []
65
90
  results.each do |row|
66
91
  table_name = row["name"]
67
- row["sql"].scan(re).each do |column_names, references_table_name, references_column_names, d1, on_update, d2, on_delete|
92
+ row["sql"].scan(re).each do |d0, name, column_names, references_table_name, references_column_names, d1, on_update, d2, on_delete|
68
93
  column_names = column_names.gsub('`', '').split(', ')
69
94
 
70
95
  references_column_names = references_column_names.gsub('`"', '').split(', ')
71
96
  on_update = on_update ? on_update.downcase.gsub(' ', '_').to_sym : :no_action
72
97
  on_delete = on_delete ? on_delete.downcase.gsub(' ', '_').to_sym : :no_action
73
- foreign_keys << ForeignKeyDefinition.new(nil,
98
+ foreign_keys << ForeignKeyDefinition.new(name,
74
99
  table_name, column_names,
75
100
  references_table_name, references_column_names,
76
101
  on_update, on_delete)
@@ -44,7 +44,7 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
44
44
  # end
45
45
  #
46
46
  # create_table :posts do |t| # Dryest
47
- # t.integer :author_id, :references => :authors
47
+ # t.integer :author_id, :foreign_key => true
48
48
  # end
49
49
  #
50
50
  # <b>NOTE:</b> In the standard configuration, SchemaPlus automatically
@@ -144,5 +144,31 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
144
144
  foreign_key(*args)
145
145
  end
146
146
 
147
+ # This is a deliberately empty stub. The reason for it is that
148
+ # ColumnOptionsHandler is used for changes as well as for table
149
+ # definitions, and in the case of changes, previously existing foreign
150
+ # keys sometimes need to be removed. but in the case here, that of
151
+ # table definitions, the only reason a foreign key would exist is
152
+ # because we're redefining a table that already exists (via :force =>
153
+ # true). in which case the foreign key will get dropped when the
154
+ # drop_table gets emitted, so no need to do it immediately. (and for
155
+ # sqlite3, attempting to do it immediately would raise an error).
156
+ def remove_foreign_key(_, *args) #:nodoc:
157
+ end
158
+
159
+ # This is a deliberately empty stub. In fact, verifying that it won't
160
+ # ever be called. The reason for it is that ColumnOptionsHandler will
161
+ # remove a previous index when changing a column. But we don't do
162
+ # column changes within table definitions.
163
+ def remove_index(_, options) raise "InternalError: remove_index called in a table definition" ; end
164
+
165
+ # Determines if an indexes is queued to be created. Called from
166
+ # ColumnOptionsHandler as part of checking whether to auto-create an index
167
+ def index_exists?(_, column_name, options={})
168
+ @indexes.find{|index| index.table == self.name && index.columns == Array.wrap(column_name) && options.all?{|k, v| index.send(k) == v}}
169
+ end
170
+
171
+
172
+
147
173
  end
148
174
  end
@@ -0,0 +1,19 @@
1
+ require 'singleton'
2
+
3
+ module SchemaPlus
4
+ module ActiveRecord
5
+ class DbDefault
6
+ include Singleton
7
+ def to_s
8
+ 'DEFAULT'
9
+ end
10
+ def id
11
+ self
12
+ end
13
+ def quoted_id
14
+ self
15
+ end
16
+ end
17
+ DB_DEFAULT = DbDefault.instance
18
+ end
19
+ end
@@ -33,20 +33,35 @@ module SchemaPlus::ActiveRecord
33
33
  #
34
34
  # == Foreign Key Constraints
35
35
  #
36
- # The +:references+ option takes the name of a table to reference in
37
- # a foreign key constraint. For example:
36
+ # The +:foreign_key+ option controls creation of foreign key
37
+ # constraints. Specifying +true+ or an empty hash defines a foreign
38
+ # key with default values. In particular, the foreign table name
39
+ # defaults to the column name, with trailing +_id+ removed, pluralized;
40
+ # And the foreign column name defaults to +:id+
38
41
  #
39
- # add_column('widgets', 'color', :integer, :references => 'colors')
42
+ # add_column('widgets', 'color', :integer, :foreign_key => true)
43
+ #
44
+ # is equivalent to
45
+ #
46
+ # add_column('widgets', 'color_id', :integer)
47
+ # add_foreign_key('widgets', 'color_id', 'colors', 'id')
48
+ #
49
+ # As a special case, if the column is named 'parent_id', SchemaPlus
50
+ # assumes it's a self reference, for a record that acts as a node of
51
+ # a tree. Thus, these are equivalent:
52
+ #
53
+ # add_column('sections', 'parent_id', :integer, :foreign_key => true)
40
54
  #
41
55
  # is equivalent to
42
56
  #
43
- # add_column('widgets', 'color', :integer)
44
- # add_foreign_key('widgets', 'color', 'colors', 'id')
57
+ # add_column('sections', 'parent_id', :integer)
58
+ # add_foreign_key('sections', 'parent_id', 'sections', 'id')
45
59
  #
46
- # The foreign column name defaults to +id+, but a different column
47
- # can be specified using <tt>:references => [table_name,column_name]</tt>
60
+ # A different foreign table name can be specified using
61
+ # <tt>:foreign_key => { :references => table_name }</tt>, and
62
+ # a different column name can also be specified using <tt>:foreign_key => { :references => [table_name,column_name] }</tt>
48
63
  #
49
- # Additional options +:on_update+ and +:on_delete+ can be spcified,
64
+ # Additional options +:on_update+ and +:on_delete+ can be specified,
50
65
  # with values as described at ConnectionAdapters::ForeignKeyDefinition. For example:
51
66
  #
52
67
  # add_column('comments', 'post', :integer, :references => 'posts', :on_delete => :cascade)
@@ -54,34 +69,35 @@ module SchemaPlus::ActiveRecord
54
69
  # Global default values for +:on_update+ and +:on_delete+ can be
55
70
  # specified in SchemaPlus.steup via, e.g., <tt>config.foreign_keys.on_update = :cascade</tt>
56
71
  #
72
+ # The constraint will have an automatic default name, but you can
73
+ # specify a constraint name using <tt>:foreign_key => { :name => "my_name" }</tt>
74
+ #
57
75
  # == Automatic Foreign Key Constraints
58
76
  #
59
77
  # SchemaPlus supports the convention of naming foreign key columns
60
78
  # with a suffix of +_id+. That is, if you define a column suffixed
61
- # with +_id+, SchemaPlus assumes an implied :references to a table
62
- # whose name is the column name prefix, pluralized. For example,
63
- # these are equivalent:
79
+ # with +_id+, SchemaPlus assumes that you want a foreign key constraint
80
+ # with default paramters. Thus, these two are equivalent:
64
81
  #
65
82
  # add_column('posts', 'author_id', :integer)
66
- # add_column('posts', 'author_id', :integer, :references => 'authors')
67
- #
68
- # As a special case, if the column is named 'parent_id', SchemaPlus
69
- # assumes it's a self reference, for a record that acts as a node of
70
- # a tree. Thus, these are equivalent:
71
- #
72
- # add_column('sections', 'parent_id', :integer)
73
- # add_column('sections', 'parent_id', :integer, :references => 'sections')
74
- #
75
- # If the implicit +:references+ value isn't what you want (e.g., the
76
- # table name isn't pluralized), you can explicitly specify
77
- # +:references+ and it will override the implicit value.
83
+ # add_column('posts', 'author_id', :integer, :foreign_key => true)
78
84
  #
79
85
  # If you don't want a foreign key constraint to be created, specify
80
- # <tt>:references => nil</tt>.
86
+ # <tt>:foreign_key => false</tt>.
81
87
  # To disable automatic foreign key constraint creation globally, set
82
88
  # <tt>config.foreign_keys.auto_create = false</tt> in
83
89
  # SchemaPlus.steup.
84
90
  #
91
+ # == Shortcut options
92
+ #
93
+ # As a shortcut (and for backwards compatibility), the options
94
+ # +:references+, +:on_update+, and +:on_delete+ can provided to
95
+ # +add_column+ directly instead of within a +:foreign_key+ hash.
96
+ #
97
+ # The presence of option +:references+ implies the foreign
98
+ # key should be created, while <tt>:references => nil</tt> is a
99
+ # shortcut for <tt>:foreign_key => false</tt>
100
+ #
85
101
  # == Automatic Foreign Key Indexes
86
102
  #
87
103
  # Since efficient use of foreign key constraints requires that the
@@ -112,16 +128,8 @@ module SchemaPlus::ActiveRecord
112
128
  # Enhances ActiveRecord::Migration#change_column to support indexes and foreign keys same as add_column.
113
129
  def change_column(table_name, column_name, type, options = {})
114
130
  super
115
- remove_foreign_key_if_exists(table_name, column_name)
116
131
  schema_plus_handle_column_options(table_name, column_name, options)
117
132
  end
118
133
 
119
- protected
120
- def remove_foreign_key_if_exists(table_name, column_name) #:nodoc:
121
- foreign_keys = ActiveRecord::Base.connection.foreign_keys(table_name.to_s)
122
- fk = foreign_keys.detect { |fk| fk.table_name == table_name.to_s && fk.column_names == Array(column_name).collect(&:to_s) }
123
- remove_foreign_key(table_name, fk.name) if fk
124
- end
125
-
126
134
  end
127
135
  end
@@ -64,7 +64,10 @@ module SchemaPlus
64
64
  @inline_fks[table] = @connection.foreign_keys(table)
65
65
  dependencies = @inline_fks[table].collect(&:references_table_name)
66
66
  end
67
- @dump_dependencies[table] = dependencies.sort.uniq - ::ActiveRecord::SchemaDumper.ignore_tables
67
+ # select against @table_dumps keys to respect filtering based on
68
+ # SchemaDumper.ignore_tables (which was taken into account
69
+ # increate @table_dumps)
70
+ @dump_dependencies[table] = dependencies.sort.uniq.select {|name| @table_dumps.has_key? name}
68
71
  end
69
72
 
70
73
  # Normally we dump foreign key constraints inline in the table
@@ -101,7 +104,7 @@ module SchemaPlus
101
104
  stream_string = stream.string
102
105
  @connection.columns(table).each do |column|
103
106
  if !column.default_expr.nil?
104
- stream_string.gsub!("\"#{column.name}\"", "\"#{column.name}\", :default => { :expr => \"#{column.default_expr}\" }")
107
+ stream_string.gsub!("\"#{column.name}\"", "\"#{column.name}\", :default => { :expr => #{column.default_expr.inspect} }")
105
108
  end
106
109
  end
107
110
  @table_dumps[table] = stream_string
@@ -123,6 +126,7 @@ module SchemaPlus
123
126
  dump << ", :conditions => #{index.conditions.inspect}" unless index.conditions.blank?
124
127
  index_lengths = index.lengths.compact if index.lengths.is_a?(Array)
125
128
  dump << ", :length => #{Hash[*index.columns.zip(index.lengths).flatten].inspect}" if index_lengths.present?
129
+ dump << ", :order => {" + index.columns.map{|column| column.inspect + " => " + (index.orders[column] || :asc).inspect}.join(", ") + "}" if index.orders
126
130
  else
127
131
  dump << " :name => #{index.name.inspect}"
128
132
  dump << ", :kind => \"#{index.kind}\"" unless index.kind.blank?
@@ -133,7 +137,7 @@ module SchemaPlus
133
137
  end
134
138
 
135
139
  def dump_foreign_keys(foreign_keys, opts={}) #:nodoc:
136
- foreign_keys.collect{ |foreign_key| " " + foreign_key.to_dump(:inline => opts[:inline]) }.join
140
+ foreign_keys.collect{ |foreign_key| " " + foreign_key.to_dump(:inline => opts[:inline]) }.sort.join
137
141
  end
138
142
  end
139
143
  end
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "0.4.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/runspecs CHANGED
@@ -4,8 +4,8 @@ require 'optparse'
4
4
  require 'ostruct'
5
5
  require 'tempfile'
6
6
 
7
- RUBY_VERSIONS = %W[1.8.7 1.9.2 1.9.3]
8
- RAILS_VERSIONS = %W[2.3 3.0 3.1 3.2]
7
+ RUBY_VERSIONS = %W[1.9.2 1.9.3]
8
+ RAILS_VERSIONS = %W[3.2]
9
9
  DB_ADAPTERS = %W[postgresql mysql mysql2 sqlite3]
10
10
 
11
11
  o = OpenStruct.new
@@ -58,13 +58,9 @@ end.parse!
58
58
  Combo = Struct.new(:ruby, :rails, :db_adapter)
59
59
 
60
60
 
61
- if o.update or o.install
62
- o.db_adapters = [nil]
63
- end
64
-
65
61
  combos = o.ruby_versions.product(o.rails_versions, o.db_adapters).map{|product| Combo.new(*product)}.select {|combo|
66
62
  case
67
- when combo.rails >= "3.2" && combo.ruby <= "1.8.7" then false
63
+ when combo.rails >= "3.2" && combo.ruby <= "1.8.7" then false # no longer happens, just keeping it as an example
68
64
  else true
69
65
  end
70
66
  }
@@ -86,7 +82,7 @@ combos.each_with_index do |combo, n|
86
82
  "bundle exec rake #{db_adapter}:spec"
87
83
  end
88
84
 
89
- command = %Q{BUNDLE_GEMFILE="#{File.join(GEMFILES_DIR, "Gemfile.rails-#{rails}")}" rvm #{ruby} do #{cmd}}
85
+ command = %Q{BUNDLE_GEMFILE="#{File.join(GEMFILES_DIR, "rails-#{rails}", "Gemfile.#{db_adapter}")}" rvm #{ruby} do #{cmd}}
90
86
 
91
87
  puts "\n\n*** ruby version #{ruby} - rails version #{rails} - db adapter: #{db_adapter} [#{n+1} of #{combos.size}]\n\n#{command}"
92
88
 
@@ -99,3 +95,4 @@ combos.each_with_index do |combo, n|
99
95
  end
100
96
  end
101
97
  puts errs.any? ? "\n*** #{errs.size} failures:\n\t#{errs.join("\n\t")}" : "\n*** #{combos.size > 1 ? 'all versions' : 'spec'} succeeded ***" unless o.dry_run
98
+ exit !errs.any?
data/schema_plus.gemspec CHANGED
@@ -20,14 +20,11 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency("rails")
23
+ s.add_dependency("rails", ">= 3.2")
24
24
  s.add_dependency("valuable")
25
25
 
26
- s.add_development_dependency("rake", "~> 0.8.7")
26
+ s.add_development_dependency("rake")
27
27
  s.add_development_dependency("rspec")
28
- s.add_development_dependency("pg")
29
- s.add_development_dependency("mysql")
30
- s.add_development_dependency("sqlite3")
31
28
  s.add_development_dependency("simplecov")
32
29
  s.add_development_dependency("simplecov-gem-adapter")
33
30
  end
@@ -3,7 +3,24 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe "Column definition" do
5
5
  before(:all) do
6
- load_core_schema
6
+ define_schema(:auto_create => false) do
7
+ create_table :users, :force => true do |t|
8
+ t.string :login
9
+ t.datetime :deleted_at
10
+ end
11
+
12
+ create_table :posts, :force => true do |t|
13
+ t.text :body
14
+ t.integer :user_id
15
+ t.integer :author_id
16
+ end
17
+
18
+ create_table :comments, :force => true do |t|
19
+ t.text :body
20
+ t.integer :post_id
21
+ t.foreign_key :post_id, :posts, :id
22
+ end
23
+ end
7
24
  end
8
25
 
9
26
  let(:connection) { ActiveRecord::Base.connection }
data/spec/column_spec.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- require 'models/user'
4
-
5
3
  describe "Column" do
4
+
5
+ before(:all) do
6
+ class User < ::ActiveRecord::Base ; end
7
+ end
8
+
6
9
  let(:migration) { ::ActiveRecord::Migration }
7
10
 
8
11
  context "regarding indexes" do
@@ -82,6 +85,40 @@ describe "Column" do
82
85
 
83
86
  end
84
87
 
88
+ context "using DB_DEFAULT" do
89
+
90
+ before(:each) do
91
+ create_table(User, :alpha => { :default => "gabba" }, :beta => {})
92
+ end
93
+
94
+ if SchemaPlusHelpers.sqlite3?
95
+ it "creating a record should raise an error" do
96
+ expect { User.create!(:alpha => ActiveRecord::DB_DEFAULT, :beta => "hello") }.to raise_error ActiveRecord::StatementInvalid
97
+ end
98
+ it "updating a record should raise an error" do
99
+ u = User.create!(:alpha => "hey", :beta => "hello")
100
+ expect { u.update_attributes(:alpha => ActiveRecord::DB_DEFAULT, :beta => "goodbye") }.to raise_error ActiveRecord::StatementInvalid
101
+ end
102
+ else
103
+
104
+ it "creating a record should respect default expression" do
105
+ User.create!(:alpha => ActiveRecord::DB_DEFAULT, :beta => "hello")
106
+ User.last.alpha.should == "gabba"
107
+ User.last.beta.should == "hello"
108
+ end
109
+
110
+ it "updating a record should respect default expression" do
111
+ u = User.create!(:alpha => "hey", :beta => "hello")
112
+ u.reload
113
+ u.alpha.should == "hey"
114
+ u.beta.should == "hello"
115
+ u.update_attributes(:alpha => ActiveRecord::DB_DEFAULT, :beta => "goodbye")
116
+ u.reload
117
+ u.alpha.should == "gabba"
118
+ u.beta.should == "goodbye"
119
+ end
120
+ end
121
+ end
85
122
 
86
123
  protected
87
124
 
@@ -5,6 +5,6 @@ describe "Connection" do
5
5
  it "should re-open without failure" do
6
6
  expect {
7
7
  ActiveRecord::Base.establish_connection "schema_plus"
8
- }.should_not raise_error
8
+ }.to_not raise_error
9
9
  end
10
10
  end
@@ -6,7 +6,7 @@ ActiveRecord::Base.logger = Logger.new(File.open("mysql.log", "w"))
6
6
  ActiveRecord::Base.configurations = {
7
7
  'schema_plus' => {
8
8
  :adapter => 'mysql',
9
- :database => 'schema_plus_unittest',
9
+ :database => 'schema_plus_test',
10
10
  :username => ENV.fetch('MYSQL_DB_USER', 'schema_plus'),
11
11
  :encoding => 'utf8',
12
12
  :min_messages => 'warning'
@@ -6,7 +6,7 @@ ActiveRecord::Base.logger = Logger.new(File.open("mysql2.log", "w"))
6
6
  ActiveRecord::Base.configurations = {
7
7
  'schema_plus' => {
8
8
  :adapter => 'mysql2',
9
- :database => 'schema_plus_unittest',
9
+ :database => 'schema_plus_test',
10
10
  :username => ENV.fetch('MYSQL_DB_USER', 'schema_plus'),
11
11
  :encoding => 'utf8',
12
12
  :min_messages => 'warning'
@@ -7,7 +7,7 @@ ActiveRecord::Base.configurations = {
7
7
  'schema_plus' => {
8
8
  :adapter => 'postgresql',
9
9
  :username => ENV['POSTGRES_DB_USER'],
10
- :database => 'schema_plus_unittest',
10
+ :database => 'schema_plus_test',
11
11
  :min_messages => 'warning'
12
12
  }
13
13