ridgepole 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/lib/ridgepole/delta.rb +1 -1
  4. data/lib/ridgepole/version.rb +1 -1
  5. data/ridgepole.gemspec +5 -2
  6. metadata +3 -279
  7. data/.github/workflows/test.yml +0 -70
  8. data/.gitignore +0 -25
  9. data/spec/cli_helper.rb +0 -65
  10. data/spec/dsl_parser/context_spec.rb +0 -16
  11. data/spec/erb_helper.rb +0 -26
  12. data/spec/fixtures/for_require_relative_spec.rb +0 -3
  13. data/spec/hide_pending_formatter.rb +0 -9
  14. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
  15. data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
  16. data/spec/mysql/cli/config_spec.rb +0 -210
  17. data/spec/mysql/cli/ridgepole_spec.rb +0 -447
  18. data/spec/mysql/collation/collation_spec.rb +0 -153
  19. data/spec/mysql/comment/comment_spec.rb +0 -179
  20. data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
  21. data/spec/mysql/diff/diff2_spec.rb +0 -189
  22. data/spec/mysql/diff/diff_spec.rb +0 -168
  23. data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
  24. data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
  25. data/spec/mysql/dump/dump_spec.rb +0 -74
  26. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
  27. data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
  28. data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
  29. data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
  30. data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
  31. data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
  32. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
  33. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
  34. data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
  35. data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
  36. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
  37. data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
  38. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -276
  39. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
  40. data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
  41. data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
  42. data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
  43. data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
  44. data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
  45. data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -34
  46. data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
  47. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
  48. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
  49. data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
  50. data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
  51. data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
  52. data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
  53. data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
  54. data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
  55. data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
  56. data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
  57. data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
  58. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
  59. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
  60. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
  61. data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
  62. data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
  63. data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
  64. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
  65. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
  66. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
  67. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
  68. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
  69. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
  70. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
  71. data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
  72. data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
  73. data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
  74. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
  75. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
  76. data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
  77. data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
  78. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
  79. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
  80. data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
  81. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
  82. data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
  83. data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
  84. data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
  85. data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
  86. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
  87. data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
  88. data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
  89. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
  90. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
  91. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
  92. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
  93. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
  94. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
  95. data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
  96. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
  97. data/spec/mysql/ridgepole_test_database.sql +0 -2
  98. data/spec/mysql/ridgepole_test_tables.sql +0 -79
  99. data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
  100. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
  101. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  102. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
  103. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  104. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
  105. data/spec/mysql57/json/add_json_column_spec.rb +0 -35
  106. data/spec/mysql57/json/change_json_column_spec.rb +0 -102
  107. data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
  108. data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
  109. data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
  110. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
  111. data/spec/postgresql/diff/diff_spec.rb +0 -216
  112. data/spec/postgresql/dump/dump_spec.rb +0 -69
  113. data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
  114. data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
  115. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
  116. data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
  117. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
  118. data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
  119. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
  120. data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
  121. data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
  122. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
  123. data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
  124. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
  125. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
  126. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
  127. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
  128. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
  129. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
  130. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
  131. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
  132. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
  133. data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
  134. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
  135. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
  136. data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
  137. data/spec/postgresql/ridgepole_test_database.sql +0 -16
  138. data/spec/postgresql/ridgepole_test_tables.sql +0 -75
  139. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  140. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
  141. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  142. data/spec/processing_for_ci.rb +0 -13
  143. data/spec/spec_condition.rb +0 -58
  144. data/spec/spec_const.rb +0 -20
  145. data/spec/spec_helper.rb +0 -173
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when drop fk' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "parent", force: :cascade do |t|
8
- end
9
-
10
- create_table "child", force: :cascade do |t|
11
- t.integer "parent_id"
12
- t.index ["parent_id"], name: "par_id"
13
- end
14
-
15
- add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
16
- ERB
17
- end
18
-
19
- let(:sorted_actual_dsl) do
20
- expected_dsl + <<-RUBY
21
- add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
22
- RUBY
23
- end
24
-
25
- let(:expected_dsl) do
26
- erbh(<<-ERB)
27
- create_table "child", force: :cascade do |t|
28
- t.integer "parent_id"
29
- t.index ["parent_id"], name: "par_id"
30
- end
31
-
32
- create_table "parent", force: :cascade do |t|
33
- end
34
- ERB
35
- end
36
-
37
- before { subject.diff(actual_dsl).migrate }
38
- subject { client(dump_with_default_fk_name: true) }
39
-
40
- it {
41
- delta = subject.diff(expected_dsl)
42
- expect(delta.differ?).to be_truthy
43
- expect(subject.dump).to match_fuzzy sorted_actual_dsl
44
- delta.migrate
45
- expect(subject.dump).to match_ruby expected_dsl
46
- }
47
-
48
- it {
49
- delta = client(bulk_change: true, dump_with_default_fk_name: true).diff(expected_dsl)
50
- expect(delta.differ?).to be_truthy
51
- expect(subject.dump).to match_fuzzy sorted_actual_dsl
52
- expect(delta.script).to match_fuzzy <<-RUBY
53
- remove_foreign_key("child", name: "fk_rails_e74ce85cbc")
54
- RUBY
55
- delta.migrate
56
- expect(subject.dump).to match_ruby expected_dsl
57
- }
58
- end
59
-
60
- context 'when drop fk when drop table' do
61
- let(:dsl) do
62
- erbh(<<-ERB)
63
- create_table "parent", force: :cascade do |t|
64
- end
65
-
66
- create_table "child", force: :cascade do |t|
67
- t.integer "parent_id", unsigned: true
68
- t.index ["parent_id"], name: "par_id"
69
- end
70
-
71
- add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
72
- ERB
73
- end
74
-
75
- let(:sorted_dsl) do
76
- erbh(<<-ERB)
77
- create_table "child", force: :cascade do |t|
78
- t.integer "parent_id"
79
- t.index ["parent_id"], name: "par_id"
80
- end
81
-
82
- create_table "parent", force: :cascade do |t|
83
- end
84
-
85
- add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
86
- ERB
87
- end
88
-
89
- before { subject.diff(dsl).migrate }
90
- subject { client(dump_with_default_fk_name: true) }
91
-
92
- it {
93
- delta = subject.diff('')
94
- expect(delta.differ?).to be_truthy
95
- expect(subject.dump).to match_fuzzy sorted_dsl
96
- delta.migrate
97
- expect(subject.dump).to match_fuzzy ''
98
- }
99
- end
100
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if ENV['CI']
4
- require 'simplecov'
5
- require 'simplecov-lcov'
6
-
7
- SimpleCov::Formatter::LcovFormatter.config do |c|
8
- c.report_with_single_file = true
9
- c.single_report_path = 'coverage/lcov.info'
10
- end
11
- SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::LcovFormatter])
12
- SimpleCov.start
13
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_record'
4
-
5
- module SpecCondition
6
- class << self
7
- def postgresql?
8
- ENV['POSTGRESQL'] == '1'
9
- end
10
-
11
- def mysql57?
12
- ENV['MYSQL57'] == '1'
13
- end
14
-
15
- def activerecord_5?
16
- (ActiveRecord::VERSION::MAJOR >= 5) && (ActiveRecord::VERSION::MAJOR < 6)
17
- end
18
-
19
- def debug?
20
- ENV['DEBUG'] == '1'
21
- end
22
-
23
- def verbose?
24
- ENV['VERBOSE'] == '1'
25
- end
26
- end
27
-
28
- def check_version_or_cond(version_or_cond)
29
- case version_or_cond
30
- when Regexp
31
- ActiveRecord::VERSION::STRING =~ version_or_cond
32
- when Float
33
- ActiveRecord::VERSION::STRING.start_with?(version_or_cond.to_s)
34
- when /\s+/
35
- ar_version = Gem::Version.new(ActiveRecord::VERSION::STRING)
36
-
37
- version_or_cond.split(',').all? do |ope_version|
38
- ope, version = ope_version.strip.split(/\s+/, 2)
39
- ar_version.send(ope, Gem::Version.new(version))
40
- end
41
- when String
42
- ActiveRecord::VERSION::STRING.start_with?(version_or_cond)
43
- else
44
- SpecCondition.send("#{version_or_cond}?")
45
- end
46
- end
47
-
48
- def condition(*conds)
49
- conds.any? do |c|
50
- if c.is_a? Array
51
- c.all? { |i| check_version_or_cond(i) }
52
- else
53
- check_version_or_cond(c)
54
- end
55
- end
56
- end
57
- end
58
- include SpecCondition
data/spec/spec_const.rb DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- TEST_MYSQL_HOST = ENV['DOCKER_HOST'] ? ENV['DOCKER_HOST'].gsub(%r{\Atcp://|:\d+\z}, '') : '127.0.0.1'
4
- TEST_MYSQL_PORT = ENV['MYSQL57'] == '1' ? 13_317 : 13_316
5
- TEST_MYSQL_USER = 'root'
6
- TEST_MYSQL_PASS = 'password'
7
-
8
- MYSQL_CLI = "mysql -h #{TEST_MYSQL_HOST} -P #{TEST_MYSQL_PORT} -u #{TEST_MYSQL_USER} -p#{TEST_MYSQL_PASS} --ssl-mode=DISABLED 2>/dev/null"
9
-
10
- TEST_PG_HOST = ENV['DOCKER_HOST'] ? ENV['DOCKER_HOST'].gsub(%r{\Atcp://|:\d+\z}, '') : '127.0.0.1'
11
- TEST_PG_PORT = 15_442
12
- TEST_PG_USER = 'postgres'
13
- TEST_PG_PASS = 'password'
14
-
15
- PG_CLI_OPTS = "PGPASSWORD=#{TEST_PG_PASS} %s -h #{TEST_PG_HOST} -p #{TEST_PG_PORT} -U #{TEST_PG_USER}"
16
- PG_PSQL = PG_CLI_OPTS % 'psql'
17
- PG_CREATEDB = PG_CLI_OPTS % 'createdb'
18
- PG_DUMP = PG_CLI_OPTS % 'pg_dump'
19
-
20
- TEST_SCHEMA = 'ridgepole_test'
data/spec/spec_helper.rb DELETED
@@ -1,173 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH << File.expand_path(__dir__)
4
-
5
- require 'spec_const'
6
- require 'spec_condition'
7
- require 'cli_helper'
8
- require 'hide_pending_formatter'
9
-
10
- require 'processing_for_ci'
11
-
12
- require 'ridgepole'
13
- require 'ridgepole/cli/config'
14
- require 'active_support/core_ext'
15
- require 'open3'
16
- require 'tempfile'
17
- require 'json'
18
- require 'rspec/match_fuzzy'
19
- require 'rspec/match_ruby'
20
- require 'erbh'
21
- require 'hash_modern_inspect'
22
- require 'hash_order_helper'
23
-
24
- require 'erb_helper'
25
-
26
- RSpec.configure do |config|
27
- config.before(:all) do
28
- if condition(:debug) || condition(:verbose)
29
- ActiveRecord::Migration.verbose = true
30
- logger = Ridgepole::Logger.instance
31
- logger.level = ::Logger::DEBUG
32
- logger.verbose = condition(:verbose)
33
- ActiveRecord::Base.logger = logger
34
- else
35
- ActiveRecord::Migration.verbose = false
36
- Ridgepole::Logger.instance.level = ::Logger::ERROR
37
- end
38
- end
39
-
40
- config.before(:each) do |example|
41
- conds = example.metadata[:condition]
42
-
43
- if conds
44
- skip unless Array(conds).any? { |c| condition(*c) }
45
- end
46
-
47
- case example.metadata[:file_path]
48
- when /mysql57/
49
- skip unless condition(:mysql57)
50
- when /mysql/
51
- skip if condition(:postgresql)
52
- when /postgresql/
53
- skip unless condition(:postgresql)
54
- end
55
-
56
- restore_database
57
- end
58
- end
59
-
60
- module SpecHelper
61
- def restore_database
62
- if condition(:postgresql)
63
- restore_database_postgresql
64
- else
65
- restore_database_mysql
66
- end
67
- end
68
-
69
- def system_raise_on_fail(*args)
70
- raise "Failed to run: #{args}" unless system(*args)
71
- end
72
-
73
- def restore_database_mysql
74
- sql_file = File.expand_path('mysql/ridgepole_test_database.sql', __dir__)
75
- system_raise_on_fail("#{MYSQL_CLI} < #{sql_file}")
76
- end
77
-
78
- def restore_database_postgresql
79
- sql_file = File.expand_path('postgresql/ridgepole_test_database.sql', __dir__)
80
- system("#{PG_CREATEDB} ridgepole_test 2>/dev/null")
81
- system_raise_on_fail("#{PG_PSQL} ridgepole_test --set ON_ERROR_STOP=off -q -f #{sql_file} 2>/dev/null")
82
- end
83
-
84
- def restore_tables
85
- if condition(:postgresql)
86
- restore_tables_postgresql
87
- else
88
- restore_tables_mysql
89
- end
90
- end
91
-
92
- def restore_tables_mysql
93
- sql_file = File.expand_path('mysql/ridgepole_test_tables.sql', __dir__)
94
- system_raise_on_fail("#{MYSQL_CLI} < #{sql_file}")
95
- end
96
-
97
- def restore_tables_postgresql
98
- sql_file = File.expand_path('postgresql/ridgepole_test_tables.sql', __dir__)
99
- system_raise_on_fail("#{PG_PSQL} ridgepole_test -q -f #{sql_file} 2>/dev/null")
100
- end
101
-
102
- def restore_tables_mysql_unknown_column_type
103
- sql_file = File.expand_path('mysql/ridgepole_test_tables_unknown_column_type.sql', __dir__)
104
- system_raise_on_fail("#{MYSQL_CLI} < #{sql_file}")
105
- end
106
-
107
- def client(options = {}, config = {})
108
- config = conn_spec(config)
109
- default_options = { debug: condition(:debug) }
110
- default_options[:dump_without_table_options] = true
111
-
112
- options = default_options.merge(options)
113
-
114
- Ridgepole::Client.new(config, options)
115
- end
116
-
117
- def conn_spec(config = {})
118
- if condition(:postgresql)
119
- {
120
- adapter: 'postgresql',
121
- database: TEST_SCHEMA,
122
- host: TEST_PG_HOST,
123
- port: TEST_PG_PORT,
124
- username: TEST_PG_USER,
125
- password: TEST_PG_PASS,
126
- }.merge(config)
127
- else
128
- {
129
- adapter: 'mysql2',
130
- database: TEST_SCHEMA,
131
- host: TEST_MYSQL_HOST,
132
- port: TEST_MYSQL_PORT,
133
- username: TEST_MYSQL_USER,
134
- password: TEST_MYSQL_PASS,
135
- ssl_mode: 'DISABLED',
136
- }.merge(config)
137
- end
138
- end
139
-
140
- def show_create_table(table_name)
141
- if condition(:postgresql)
142
- show_create_table_postgresql(table_name)
143
- else
144
- show_create_table_mysql(table_name)
145
- end
146
- end
147
-
148
- def show_create_table_mysql(table_name)
149
- raw_conn = ActiveRecord::Base.connection.raw_connection
150
- raw_conn.query("SHOW CREATE TABLE `#{table_name}`").first[1]
151
- end
152
-
153
- def show_create_table_postgresql(table_name)
154
- `#{PG_DUMP} --schema-only #{TEST_SCHEMA} --table=#{table_name} | awk '/^CREATE TABLE/,/);/{print} /^CREATE INDEX/{print}'`.strip
155
- end
156
-
157
- def tempfile(basename, content = '')
158
- path = `mktemp /tmp/#{basename}.XXXXXX`
159
- File.open(path, 'wb') { |f| f << content }
160
- FileUtils.chmod(0o777, path)
161
- yield(path)
162
- ensure
163
- FileUtils.rm_f(path) if path
164
- end
165
-
166
- def run_ridgepole(*args)
167
- Dir.chdir(File.expand_path('..', __dir__)) do
168
- cmd = [:bundle, :exec, './bin/ridgepole'] + args
169
- Open3.capture2e(cmd.join(' '))
170
- end
171
- end
172
- end
173
- include SpecHelper