ardb 0.28.3 → 0.30.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 (60) hide show
  1. checksums.yaml +7 -7
  2. data/.l.yml +9 -0
  3. data/.rubocop.yml +3 -0
  4. data/.ruby-version +1 -0
  5. data/.t.yml +6 -0
  6. data/Gemfile +24 -8
  7. data/README.md +252 -3
  8. data/ardb.gemspec +14 -10
  9. data/bin/ardb +3 -1
  10. data/lib/ardb/adapter/base.rb +72 -47
  11. data/lib/ardb/adapter/mysql.rb +4 -17
  12. data/lib/ardb/adapter/postgresql.rb +51 -46
  13. data/lib/ardb/adapter/sqlite.rb +11 -15
  14. data/lib/ardb/adapter_spy.rb +18 -30
  15. data/lib/ardb/cli/clirb.rb +16 -18
  16. data/lib/ardb/cli/commands.rb +308 -129
  17. data/lib/ardb/cli.rb +29 -24
  18. data/lib/ardb/db_tests.rb +4 -4
  19. data/lib/ardb/default_order_by.rb +13 -21
  20. data/lib/ardb/migration.rb +15 -16
  21. data/lib/ardb/record_spy.rb +46 -61
  22. data/lib/ardb/relation_spy.rb +28 -32
  23. data/lib/ardb/require_autoloaded_active_record_files.rb +258 -57
  24. data/lib/ardb/test_helpers.rb +33 -29
  25. data/lib/ardb/use_db_default.rb +13 -21
  26. data/lib/ardb/version.rb +3 -1
  27. data/lib/ardb.rb +105 -86
  28. data/script/determine_autoloaded_active_record_files.rb +31 -24
  29. data/test/helper.rb +6 -13
  30. data/test/support/factory.rb +4 -3
  31. data/test/support/fake_schema.rb +3 -1
  32. data/test/support/postgresql/migrations/{.gitkeep → .keep} +0 -0
  33. data/test/support/postgresql/schema.rb +2 -1
  34. data/test/support/postgresql/setup_test_db.rb +23 -21
  35. data/test/support/relative_require_test_db_file.rb +1 -0
  36. data/test/support/require_test_db_file.rb +1 -0
  37. data/test/system/.keep +0 -0
  38. data/test/unit/adapter/base_tests.rb +80 -55
  39. data/test/unit/adapter/mysql_tests.rb +4 -19
  40. data/test/unit/adapter/postgresql_tests.rb +21 -30
  41. data/test/unit/adapter/sqlite_tests.rb +5 -11
  42. data/test/unit/adapter_spy_tests.rb +6 -17
  43. data/test/unit/ardb_tests.rb +75 -53
  44. data/test/unit/cli_tests.rb +234 -158
  45. data/test/unit/db_tests_tests.rb +7 -7
  46. data/test/unit/default_order_by_tests.rb +26 -24
  47. data/test/unit/migration_tests.rb +17 -18
  48. data/test/unit/record_spy_tests.rb +45 -41
  49. data/test/unit/relation_spy_tests.rb +40 -63
  50. data/test/unit/test_helpers_tests.rb +7 -15
  51. data/test/unit/use_db_default_tests.rb +35 -27
  52. metadata +109 -87
  53. data/lib/ardb/has_slug.rb +0 -107
  54. data/lib/ardb/migration_helpers.rb +0 -77
  55. data/lib/ardb/pg_json.rb +0 -90
  56. data/test/support/postgresql/pg_json_migrations/20160519133432_create_pg_json_migrate_test.rb +0 -13
  57. data/test/system/pg_json_tests.rb +0 -85
  58. data/test/unit/has_slug_tests.rb +0 -341
  59. data/test/unit/migration_helpers_tests.rb +0 -65
  60. data/test/unit/pg_json_tests.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- data.tar.gz: 352c1dc50e3ac2567d5f74cc148ba572d4fa8f3d
4
- metadata.gz: 0a5e57adec591aaa7273bade002b3f873caef819
5
- SHA512:
6
- data.tar.gz: c16e759ea474b84490ebb450825b44e11725960d847ff82cfec5e5840dd00b853a4278cc92f49989da04f6f04196b61aa428f4ba7f151f7562cd3d562ead9015
7
- metadata.gz: f61b9a4df10d7d2b5b4520d8f601c1e3f9d3e1155a306d9b477cecf63d9021546bf9123adcdfddd9747f1348a905a388d564ef4babbde667c97fd732b355e213
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f61742815afbcc9e0a4e2a450864e15297d2dc3d6e4d1b61fcaf62d87551b048
4
+ data.tar.gz: 388acb5b938c3c51a8d6f9aa1c382fe2310d7ba919c4ef9c2d62bc50c4fffc87
5
+ SHA512:
6
+ metadata.gz: c05d1cefea07609365899f0f08d067a39b326859d86e13c669163658a0f56c0b162fda248be764ecf2c0638108b302893cd58717162027ce474d5fd06cd1db5a
7
+ data.tar.gz: 5080cb134c4f67bc6a8a6280f70945c0909bcdc4975123069663f5f061c8f63054970b87898e4a9d6f77171bb9ebbc3a88f766b5607040da637713667b5e305c
data/.l.yml ADDED
@@ -0,0 +1,9 @@
1
+ # https://github.com/redding/l.rb
2
+
3
+ linters:
4
+ - name: "Rubocop"
5
+ cmd: "bundle exec rubocop"
6
+ autocorrect_cmd: "bundle exec rubocop -A"
7
+ extensions:
8
+ - ".rb"
9
+ cli_abbrev: "u"
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ inherit_gem:
2
+ much-style-guide:
3
+ - "lib/much-style-guide/rubocop.yml"
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.0
data/.t.yml ADDED
@@ -0,0 +1,6 @@
1
+ # https://github.com/redding/t.rb
2
+
3
+ default_cmd: bundle exec assert
4
+ test_dir: test
5
+ test_file_suffixes:
6
+ - "_tests.rb"
data/Gemfile CHANGED
@@ -1,13 +1,29 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- gemspec
5
+ ruby ">= 2.5"
4
6
 
5
- gem 'pg', "~> 0.17.1"
6
- gem 'pry', "~> 0.9.0"
7
+ gemspec
7
8
 
8
- # Lock down gem versions because they require a newer version of ruby
9
- gem 'i18n', "< 0.7"
9
+ # Uncomment one of these and run:
10
+ #
11
+ # bundle update activerecord activesupport
12
+ #
13
+ # to test a specific version.
14
+ #
15
+ # Rails 7.0
16
+ gem "activerecord", "~> 7.0.1"
17
+ gem "activesupport", "~> 7.0.1"
18
+ # Rails 6.1
19
+ # gem "activerecord", "~> 6.1"
20
+ # gem "activesupport", "~> 6.1"
21
+ # Rails 6.0
22
+ # gem "activerecord", "~> 6.0.3"
23
+ # gem "activesupport", "~> 6.0.3"
24
+ # Rails 5.2
25
+ # gem "activerecord", "~> 5.2.4"
26
+ # gem "activesupport", "~> 5.2.4"
10
27
 
11
- platform :ruby_18 do
12
- gem 'json', '~> 1.8'
13
- end
28
+ gem "pg", "~> 1.3"
29
+ gem "pry"
data/README.md CHANGED
@@ -1,16 +1,265 @@
1
1
  # Ardb
2
2
 
3
- Activerecord database tools.
3
+ Tools for using ActiveRecord with or without Rails.
4
4
 
5
5
  ## Usage
6
6
 
7
- TODO: Write code samples and usage instructions here
7
+ Given configured database connection parameters, Ardb provides a CLI and assorted tools for working with an ActiveRecord database. Ardb is designed to be used with or without Rails.
8
+
9
+ ### Configuration
10
+
11
+ By default, Ardb looks for database configuration in the `config/db.rb` file. You can override this using the `ENV["ARDB_DB_FILE"]` env var.
12
+
13
+ The configuration includes typical database configuration parameters:
14
+
15
+ ```ruby
16
+ # in config/db.rb
17
+ require "ardb"
18
+
19
+ Ardb.configure do |c|
20
+ c.logger Logger.new($stdout)
21
+ c.root_path File.expand_path("../..", __FILE__)
22
+
23
+ c.db.adapter "postgresql"
24
+ c.db.encoding "unicode"
25
+ c.db.min_messages "WARNING"
26
+ c.db.url "localhost:5432"
27
+ c.db.username "testuser"
28
+ c.db.password "secret"
29
+ c.db.database "testdb"
30
+ end
31
+ ```
32
+
33
+ #### Rails configuration
34
+
35
+ If using Ardb with Rails, add a `config/db.rb` file to have Ardb use Rails's configuration settings:
36
+
37
+ ```ruby
38
+ # in config/db.rb
39
+ require_relative "./environment"
40
+ require "ardb"
41
+
42
+ # This Ardb configuration matches Rails's settings.
43
+ Ardb.configure do |c|
44
+ rails_db_config = Rails.application.config_for("database")
45
+ c.root_path = Rails.root
46
+ c.logger = Rails.logger
47
+ c.schema_format = Rails.application.config.active_record.schema_format || :ruby
48
+ c.default_timezone = :utc
49
+ c.adapter = rails_db_config["adapter"]
50
+ c.host = rails_db_config["host"]
51
+ c.port = rails_db_config["port"]
52
+ c.username = rails_db_config["username"]
53
+ c.password = rails_db_config["password"]
54
+ c.database = rails_db_config["database"]
55
+ c.encoding = rails_db_config["encoding"]
56
+ c.min_messages = rails_db_config["min_messages"]
57
+
58
+ c.migrations_path = "db/migrate"
59
+ c.schema_path = "db/schema"
60
+ end
61
+ ```
62
+
63
+ ### CLI
64
+
65
+ ```
66
+ $ ardb --help
67
+ Usage: ardb [COMMAND] [options]
68
+
69
+ Options:
70
+ --version
71
+ --help
72
+
73
+ Commands:
74
+ connect Connect to the configured DB
75
+ create Create the configured DB
76
+ drop Drop the configured DB
77
+ generate-migration Generate a MIGRATION-NAME migration file
78
+ migrate Migrate the configured DB
79
+ migrate-up Migrate the configured DB up
80
+ migrate-down Migrate the configured DB down
81
+ migrate-forward Migrate the configured DB forward
82
+ migrate-backward Migrate the configured DB backward
83
+ ```
84
+
85
+ #### `connect` command
86
+
87
+ ```
88
+ $ ardb connect --help
89
+ Usage: ardb connect [options]
90
+
91
+ Options:
92
+ --version
93
+ --help
94
+
95
+ Description:
96
+ Connect to the configured DB
97
+ $ ardb connect
98
+ error: database "some_database" does not exist
99
+ $ ardb create
100
+ created postgresql db "some_database"
101
+ $ ardb connect
102
+ connected to postgresql db "some_database"
103
+ ```
104
+
105
+ Use this command to verify the connection parameter configuration is correct.
106
+
107
+ #### `create` command
108
+
109
+ ```
110
+ $ ardb create --help
111
+ Usage: ardb create [options]
112
+
113
+ Options:
114
+ --version
115
+ --help
116
+
117
+ Description:
118
+ Create the configured DB
119
+ $ ardb create
120
+ created postgresql db "some_database"
121
+ $ ardb create
122
+ error: database "some_database" already exists
123
+ ```
124
+
125
+ #### `drop` command
126
+
127
+ ```
128
+ $ ardb drop --help
129
+ Usage: ardb drop [options]
130
+
131
+ Options:
132
+ --version
133
+ --help
134
+
135
+ Description:
136
+ Drop the configured DB
137
+ $ ardb drop
138
+ dropped postgresql db "some_database"
139
+ $ ardb drop
140
+ error: database "some_database" does not exist
141
+ ```
142
+
143
+ #### `generate-migration` command
144
+
145
+ ```
146
+ $ ardb generate-migration add_projects --help
147
+ Usage: ardb generate-migration MIGRATION-NAME [options]
148
+
149
+ Options:
150
+ --version
151
+ --help
152
+
153
+ Description:
154
+ Generate a MIGRATION-NAME migration file
155
+ $ ardb generate-migration add_projects
156
+ generated /path/to/app/db/migrate/20191222074043_add_projects.rb
157
+ ```
158
+
159
+ #### `migrate` command
160
+
161
+ ```
162
+ $ ardb migrate --help
163
+ Usage: ardb migrate [options]
164
+
165
+ Options:
166
+ --version
167
+ --help
168
+
169
+ Description:
170
+ Migrate the configured DB
171
+ $ ardb migrate
172
+ == 20191222074043 AddProjects: migrating ======================================
173
+ -- create_table(:projects)
174
+ -> 0.0276s
175
+ == 20191222074043 AddProjects: migrated (0.0277s) =============================
176
+ ```
177
+
178
+ #### `migrate-up` command
179
+
180
+ ```
181
+ $ ardb migrate-up --help
182
+ Usage: ardb migrate-up [options]
183
+
184
+ Options:
185
+ -t, --target-version VALUE version to migrate to
186
+ --version
187
+ --help
188
+
189
+ Description:
190
+ Migrate the configured DB up
191
+ $ ardb migrate-up
192
+ == 20191222074043 AddProjects: migrating ======================================
193
+ -- create_table(:projects)
194
+ -> 0.0510s
195
+ == 20191222074043 AddProjects: migrated (0.0511s) =============================
196
+ ```
197
+
198
+ #### `migrate-down` command
199
+
200
+ ```
201
+ $ ardb migrate-down --help
202
+ Usage: ardb migrate-down [options]
203
+
204
+ Options:
205
+ -t, --target-version VALUE version to migrate to
206
+ --version
207
+ --help
208
+
209
+ Description:
210
+ Migrate the configured DB down
211
+ $ ardb migrate-down
212
+ == 20191222074043 AddProjects: reverting ======================================
213
+ -- drop_table(:projects)
214
+ -> 0.0092s
215
+ == 20191222074043 AddProjects: reverted (0.0132s) =============================
216
+ ```
217
+
218
+ #### `migrate-forward` command
219
+
220
+ ```
221
+ $ ardb migrate-forward --help
222
+ Usage: ardb migrate-forward [options]
223
+
224
+ Options:
225
+ -s, --steps VALUE number of migrations to migrate
226
+ --version
227
+ --help
228
+
229
+ Description:
230
+ Migrate the configured DB forward
231
+ $ ardb migrate-forward
232
+ == 20191222074043 AddProjects: migrating ======================================
233
+ -- create_table(:projects)
234
+ -> 0.0510s
235
+ == 20191222074043 AddProjects: migrated (0.0511s) =============================
236
+ ```
237
+
238
+ #### `migrate-backward` command
239
+
240
+ ```
241
+ $ ardb migrate-backward --help
242
+ Usage: ardb migrate-backward [options]
243
+
244
+ Options:
245
+ -s, --steps VALUE number of migrations to migrate
246
+ --version
247
+ --help
248
+
249
+ Description:
250
+ Migrate the configured DB backward
251
+ $ ardb migrate-backward
252
+ == 20191222074043 AddProjects: reverting ======================================
253
+ -- drop_table(:projects)
254
+ -> 0.0092s
255
+ == 20191222074043 AddProjects: reverted (0.0132s) =============================
256
+ ```
8
257
 
9
258
  ## Installation
10
259
 
11
260
  Add this line to your application's Gemfile:
12
261
 
13
- gem 'ardb'
262
+ gem "ardb"
14
263
 
15
264
  And then execute:
16
265
 
data/ardb.gemspec CHANGED
@@ -1,5 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require "ardb/version"
5
7
 
@@ -8,21 +10,23 @@ Gem::Specification.new do |gem|
8
10
  gem.version = Ardb::VERSION
9
11
  gem.authors = ["Kelly Redding", "Collin Redding"]
10
12
  gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
11
- gem.summary = %q{Activerecord database tools.}
12
- gem.description = %q{Activerecord database tools.}
13
+ gem.summary = "Activerecord database tools."
14
+ gem.description = "Activerecord database tools."
13
15
  gem.homepage = "http://github.com/redding/ardb"
14
- gem.license = 'MIT'
16
+ gem.license = "MIT"
15
17
 
16
- gem.files = `git ls-files`.split($/)
18
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
21
  gem.require_paths = ["lib"]
20
22
 
21
- gem.add_development_dependency("assert", ["~> 2.16.1"])
23
+ gem.required_ruby_version = ">= 2.5"
22
24
 
23
- gem.add_dependency('activerecord', ["~> 3.2"])
24
- gem.add_dependency('activesupport', ["~> 3.2"])
25
- gem.add_dependency('much-plugin', ["~> 0.2.0"])
26
- gem.add_dependency('scmd', ["~> 3.0.2"])
25
+ gem.add_development_dependency("much-style-guide", ["~> 0.6.7"])
26
+ gem.add_development_dependency("assert", ["~> 2.19.8"])
27
27
 
28
+ gem.add_dependency("activerecord", [">= 5.0"])
29
+ gem.add_dependency("activesupport", [">= 5.0"])
30
+ gem.add_dependency("much-mixin", ["~> 0.2.5"])
31
+ gem.add_dependency("scmd", ["~> 3.0.5"])
28
32
  end
data/bin/ardb CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # Copyright (c) 2013-Present Kelly Redding and Collin Redding
4
6
  #
5
7
 
6
- require 'ardb/cli'
8
+ require "ardb/cli"
7
9
  Ardb::CLI.run ARGV
@@ -1,27 +1,40 @@
1
- require 'ardb'
1
+ # frozen_string_literal: true
2
+
3
+ require "ardb"
2
4
 
3
5
  module Ardb; end
4
- module Ardb::Adapter
5
6
 
7
+ module Ardb::Adapter
6
8
  class Base
7
-
8
9
  attr_reader :config
9
10
 
10
11
  def initialize(config)
11
12
  @config = config
13
+ validate!
14
+ end
15
+
16
+ def connect_hash
17
+ config.activerecord_connect_hash
18
+ end
19
+
20
+ def database
21
+ config.database
12
22
  end
13
23
 
14
- def connect_hash; self.config.activerecord_connect_hash; end
15
- def database; self.config.database; end
16
- def migrations_path; self.config.migrations_path; end
17
- def schema_format; self.config.schema_format; end
24
+ def migrations_path
25
+ config.migrations_path
26
+ end
27
+
28
+ def schema_format
29
+ config.schema_format
30
+ end
18
31
 
19
32
  def ruby_schema_path
20
- @ruby_schema_path ||= "#{self.config.schema_path}.rb"
33
+ @ruby_schema_path ||= "#{config.schema_path}.rb"
21
34
  end
22
35
 
23
36
  def sql_schema_path
24
- @sql_schema_path ||= "#{self.config.schema_path}.sql"
37
+ @sql_schema_path ||= "#{config.schema_path}.sql"
25
38
  end
26
39
 
27
40
  def escape_like_pattern(pattern, escape_char = nil)
@@ -33,50 +46,55 @@ module Ardb::Adapter
33
46
  pattern
34
47
  end
35
48
 
36
- def foreign_key_add_sql(*args); raise NotImplementedError; end
37
- def foreign_key_drop_sql(*args); raise NotImplementedError; end
49
+ def create_db(*args)
50
+ raise NotImplementedError
51
+ end
38
52
 
39
- def create_db(*args); raise NotImplementedError; end
40
- def drop_db(*args); raise NotImplementedError; end
53
+ def drop_db(*args)
54
+ raise NotImplementedError
55
+ end
41
56
 
42
- def drop_tables(*args); raise NotImplementedError; end
57
+ def drop_tables(*args)
58
+ raise NotImplementedError
59
+ end
43
60
 
44
61
  def connect_db
45
- ActiveRecord::Base.establish_connection(self.connect_hash)
46
- # checkout a connection to ensure we can connect to the DB, we don't do
62
+ ActiveRecord::Base.establish_connection(connect_hash)
63
+ # checkout a connection to ensure we can connect to the DB, we don"t do
47
64
  # anything with the connection and immediately check it back in
48
- ActiveRecord::Base.connection_pool.with_connection{ }
65
+ ActiveRecord::Base.connection_pool.with_connection{}
49
66
  end
50
67
 
51
68
  def migrate_db
52
- verbose = ENV["MIGRATE_QUIET"].nil?
53
- version = ENV["MIGRATE_VERSION"] ? ENV["MIGRATE_VERSION"].to_i : nil
54
-
55
- if defined?(ActiveRecord::Migration::CommandRecorder)
56
- require 'ardb/migration_helpers'
57
- ActiveRecord::Migration::CommandRecorder.class_eval do
58
- include Ardb::MigrationHelpers::RecorderMixin
59
- end
60
- end
69
+ migrate_db_up
70
+ end
61
71
 
62
- ActiveRecord::Migrator.migrations_path = self.migrations_path
63
- ActiveRecord::Migration.verbose = verbose
64
- ActiveRecord::Migrator.migrate(self.migrations_path, version) do |migration|
65
- ENV["MIGRATE_SCOPE"].blank? || (ENV["MIGRATE_SCOPE"] == migration.scope)
66
- end
72
+ def migrate_db_up(target_version = nil)
73
+ migration_context.up(target_version)
74
+ end
75
+
76
+ def migrate_db_down(target_version = nil)
77
+ migration_context.down(target_version)
78
+ end
79
+
80
+ def migrate_db_forward(steps = 1)
81
+ migration_context.forward(steps)
82
+ end
83
+
84
+ def migrate_db_backward(steps = 1)
85
+ migration_context.rollback(steps)
67
86
  end
68
87
 
69
88
  def load_schema
70
- # silence STDOUT
71
- current_stdout = $stdout.dup
72
- $stdout = File.new('/dev/null', 'w')
73
- load_ruby_schema if self.schema_format == Ardb::Config::RUBY_SCHEMA_FORMAT
74
- load_sql_schema if self.schema_format == Ardb::Config::SQL_SCHEMA_FORMAT
89
+ current_stdout = $stdout.dup # silence STDOUT
90
+ $stdout = File.new("/dev/null", "w")
91
+ load_ruby_schema if schema_format == Ardb::Config::RUBY_SCHEMA_FORMAT
92
+ load_sql_schema if schema_format == Ardb::Config::SQL_SCHEMA_FORMAT
75
93
  $stdout = current_stdout
76
94
  end
77
95
 
78
96
  def load_ruby_schema
79
- load self.ruby_schema_path
97
+ load ruby_schema_path
80
98
  end
81
99
 
82
100
  def load_sql_schema
@@ -84,18 +102,17 @@ module Ardb::Adapter
84
102
  end
85
103
 
86
104
  def dump_schema
87
- # silence STDOUT
88
- current_stdout = $stdout.dup
89
- $stdout = File.new('/dev/null', 'w')
105
+ current_stdout = $stdout.dup # silence STDOUT
106
+ $stdout = File.new("/dev/null", "w")
90
107
  dump_ruby_schema
91
- dump_sql_schema if self.schema_format == Ardb::Config::SQL_SCHEMA_FORMAT
108
+ dump_sql_schema if schema_format == Ardb::Config::SQL_SCHEMA_FORMAT
92
109
  $stdout = current_stdout
93
110
  end
94
111
 
95
112
  def dump_ruby_schema
96
- require 'active_record/schema_dumper'
97
- FileUtils.mkdir_p File.dirname(self.ruby_schema_path)
98
- File.open(self.ruby_schema_path, 'w:utf-8') do |file|
113
+ require "active_record/schema_dumper"
114
+ FileUtils.mkdir_p File.dirname(ruby_schema_path)
115
+ File.open(ruby_schema_path, "w:utf-8") do |file|
99
116
  ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
100
117
  end
101
118
  end
@@ -105,13 +122,21 @@ module Ardb::Adapter
105
122
  end
106
123
 
107
124
  def ==(other)
108
- if other.kind_of?(self.class)
109
- self.config == other.config
125
+ if other.is_a?(self.class)
126
+ config == other.config
110
127
  else
111
128
  super
112
129
  end
113
130
  end
114
131
 
115
- end
132
+ private
116
133
 
134
+ def validate!
135
+ # override as needed
136
+ end
137
+
138
+ def migration_context
139
+ ActiveRecord::MigrationContext.new(migrations_path)
140
+ end
141
+ end
117
142
  end
@@ -1,21 +1,8 @@
1
- require 'ardb/adapter/base'
1
+ # frozen_string_literal: true
2
2
 
3
- module Ardb::Adapter
4
-
5
- class Mysql < Base
6
-
7
- def foreign_key_add_sql
8
- "ALTER TABLE :from_table"\
9
- " ADD CONSTRAINT :name"\
10
- " FOREIGN KEY (:from_column)"\
11
- " REFERENCES :to_table (:to_column)"
12
- end
13
-
14
- def foreign_key_drop_sql
15
- "ALTER TABLE :from_table"\
16
- " DROP FOREIGN KEY :name"
17
- end
3
+ require "ardb/adapter/base"
18
4
 
5
+ module Ardb::Adapter
6
+ class Mysql < Ardb::Adapter::Base
19
7
  end
20
-
21
8
  end