ridgepole 0.8.13 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +27 -20
  3. data/.rubocop.yml +5 -4
  4. data/.simplecov +6 -0
  5. data/Appraisals +4 -5
  6. data/README.md +24 -43
  7. data/bin/ridgepole +13 -3
  8. data/gemfiles/{activerecord_5.0.gemfile → activerecord_6.1.gemfile} +1 -2
  9. data/lib/ridgepole/client.rb +8 -3
  10. data/lib/ridgepole/delta.rb +16 -1
  11. data/lib/ridgepole/diff.rb +50 -31
  12. data/lib/ridgepole/dsl_parser/table_definition.rb +8 -1
  13. data/lib/ridgepole/execute_expander.rb +10 -1
  14. data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +9 -1
  15. data/lib/ridgepole/external_sql_executer.rb +12 -1
  16. data/lib/ridgepole/version.rb +1 -1
  17. data/ridgepole.gemspec +4 -3
  18. data/spec/erb_helper.rb +1 -1
  19. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +2 -2
  20. data/spec/mysql/bigint_pk/int_pk_spec.rb +1 -1
  21. data/spec/mysql/cli/ridgepole_spec.rb +35 -1
  22. data/spec/mysql/collation/collation_spec.rb +14 -14
  23. data/spec/mysql/comment/comment_spec.rb +9 -9
  24. data/spec/mysql/diff/diff2_spec.rb +5 -5
  25. data/spec/mysql/diff/diff_spec.rb +3 -3
  26. data/spec/mysql/dump/dump_class_method_spec.rb +13 -13
  27. data/spec/mysql/dump/dump_some_tables_spec.rb +4 -4
  28. data/spec/mysql/dump/dump_spec.rb +13 -13
  29. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +2 -2
  30. data/spec/mysql/dump/dump_without_table_options_spec.rb +2 -2
  31. data/spec/mysql/fk/migrate_change_fk2_spec.rb +2 -2
  32. data/spec/mysql/fk/migrate_change_fk_spec.rb +88 -20
  33. data/spec/mysql/fk/migrate_create_fk_spec.rb +77 -22
  34. data/spec/mysql/fk/migrate_drop_fk_spec.rb +81 -26
  35. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +16 -16
  36. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +6 -6
  37. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +2 -2
  38. data/spec/mysql/migrate/migrate_add_column_spec.rb +18 -18
  39. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +106 -18
  40. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +18 -18
  41. data/spec/mysql/migrate/migrate_change_column2_spec.rb +5 -5
  42. data/spec/mysql/migrate/migrate_change_column3_spec.rb +10 -10
  43. data/spec/mysql/migrate/migrate_change_column5_spec.rb +3 -3
  44. data/spec/mysql/migrate/migrate_change_column6_spec.rb +7 -7
  45. data/spec/mysql/migrate/migrate_change_column8_spec.rb +38 -5
  46. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +2 -14
  47. data/spec/mysql/migrate/migrate_change_column_spec.rb +21 -21
  48. data/spec/mysql/migrate/migrate_change_index2_spec.rb +5 -5
  49. data/spec/mysql/migrate/migrate_change_index3_spec.rb +7 -7
  50. data/spec/mysql/migrate/migrate_change_index4_spec.rb +6 -6
  51. data/spec/mysql/migrate/migrate_change_index5_spec.rb +4 -4
  52. data/spec/mysql/migrate/migrate_change_index6_spec.rb +27 -27
  53. data/spec/mysql/migrate/migrate_change_index7_spec.rb +4 -4
  54. data/spec/mysql/migrate/migrate_change_index8_spec.rb +4 -4
  55. data/spec/mysql/migrate/migrate_change_index_spec.rb +34 -28
  56. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +5 -5
  57. data/spec/mysql/migrate/migrate_create_index2_spec.rb +24 -24
  58. data/spec/mysql/migrate/migrate_create_index_spec.rb +78 -18
  59. data/spec/mysql/migrate/migrate_create_table_spec.rb +16 -16
  60. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +4 -4
  61. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +4 -4
  62. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +16 -16
  63. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +18 -18
  64. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +16 -16
  65. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +1 -1
  66. data/spec/mysql/migrate/migrate_drop_column_spec.rb +18 -18
  67. data/spec/mysql/migrate/migrate_drop_index_spec.rb +15 -15
  68. data/spec/mysql/migrate/migrate_drop_table_spec.rb +16 -16
  69. data/spec/mysql/migrate/migrate_empty_spec.rb +9 -9
  70. data/spec/mysql/migrate/migrate_execute_spec.rb +32 -32
  71. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +4 -4
  72. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +5 -5
  73. data/spec/mysql/migrate/migrate_log_file_spec.rb +16 -16
  74. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +18 -18
  75. data/spec/mysql/migrate/migrate_noop_spec.rb +12 -12
  76. data/spec/mysql/migrate/migrate_primary_key_spec.rb +31 -6
  77. data/spec/mysql/migrate/migrate_rename_column_spec.rb +18 -18
  78. data/spec/mysql/migrate/migrate_rename_table_spec.rb +22 -22
  79. data/spec/mysql/migrate/migrate_same_spec.rb +13 -13
  80. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +2 -2
  81. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +18 -18
  82. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +18 -18
  83. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +18 -18
  84. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +18 -18
  85. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +2 -2
  86. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +6 -6
  87. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +9 -9
  88. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +8 -8
  89. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +5 -5
  90. data/spec/mysql57/json/add_json_column_spec.rb +2 -2
  91. data/spec/mysql57/json/change_json_column_spec.rb +6 -6
  92. data/spec/mysql57/json/drop_json_column_spec.rb +2 -2
  93. data/spec/mysql57/virtual/add_virtual_column_spec.rb +1 -1
  94. data/spec/mysql57/virtual/change_virtual_column_spec.rb +1 -1
  95. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +1 -1
  96. data/spec/postgresql/dump/dump_spec.rb +13 -13
  97. data/spec/postgresql/fk/migrate_change_fk_spec.rb +6 -6
  98. data/spec/postgresql/fk/migrate_create_fk_spec.rb +5 -5
  99. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +8 -8
  100. data/spec/postgresql/migrate/migrate_add_column_spec.rb +16 -16
  101. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
  102. data/spec/postgresql/migrate/migrate_change_column_spec.rb +16 -16
  103. data/spec/postgresql/migrate/migrate_change_index_spec.rb +18 -18
  104. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +1 -1
  105. data/spec/postgresql/migrate/migrate_create_table_spec.rb +14 -14
  106. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +18 -18
  107. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +17 -17
  108. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
  109. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +15 -15
  110. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +16 -16
  111. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +1 -1
  112. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +1 -1
  113. data/spec/postgresql/migrate/migrate_references_spec.rb +6 -6
  114. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +18 -18
  115. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +20 -20
  116. data/spec/postgresql/migrate/migrate_same_spec.rb +13 -13
  117. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +3 -3
  118. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +4 -4
  119. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +4 -4
  120. data/spec/processing_for_ci.rb +13 -0
  121. data/spec/spec_const.rb +1 -1
  122. data/spec/spec_helper.rb +2 -1
  123. metadata +43 -46
  124. data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +0 -31
  125. data/omnibus-ridgepole/.gitignore +0 -10
  126. data/omnibus-ridgepole/Dockerfile.centos +0 -25
  127. data/omnibus-ridgepole/Dockerfile.ubuntu +0 -21
  128. data/omnibus-ridgepole/Gemfile +0 -24
  129. data/omnibus-ridgepole/README.md +0 -15
  130. data/omnibus-ridgepole/Rakefile +0 -38
  131. data/omnibus-ridgepole/config/projects/ridgepole.rb +0 -27
  132. data/omnibus-ridgepole/config/software/ridgepole.rb +0 -13
  133. data/omnibus-ridgepole/omnibus.rb +0 -54
  134. data/omnibus-ridgepole/package-scripts/ridgepole/postinst +0 -1
  135. data/omnibus-ridgepole/package-scripts/ridgepole/postrm +0 -1
  136. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +0 -47
  137. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +0 -141
  138. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +0 -141
  139. data/spec/processing_for_travis.rb +0 -11
@@ -1,10 +0,0 @@
1
- *.gem
2
- .bundle
3
- .kitchen/
4
- .kitchen.local.yml
5
- vendor/bundle
6
- pkg/*
7
- .vagrant
8
- bin/*
9
- files/**/cache/
10
- vendor/cookbooks
@@ -1,25 +0,0 @@
1
- FROM centos:7
2
-
3
- RUN yum install -y centos-release-scl && \
4
- yum-config-manager --enable rhel-server-rhscl-7-rpms && \
5
- yum install -y \
6
- rh-ruby25-dev \
7
- rh-ruby25-ruby-devel \
8
- make \
9
- gcc \
10
- gcc-c++ \
11
- git \
12
- rpm-build
13
-
14
- RUN scl enable rh-ruby25 -- \
15
- gem install --no-document \
16
- bundler \
17
- omnibus
18
-
19
- COPY Gemfile /
20
- RUN scl enable rh-ruby25 -- \
21
- bundle install
22
-
23
- WORKDIR /omnibus-ridgepole
24
-
25
- ENTRYPOINT ["/usr/bin/scl", "enable", "rh-ruby25", "--"]
@@ -1,21 +0,0 @@
1
- FROM ubuntu:xenial
2
-
3
- RUN apt-get update && \
4
- apt-get install -y software-properties-common
5
-
6
- RUN apt-add-repository -y ppa:brightbox/ruby-ng && \
7
- apt-get update && \
8
- apt-get install -y \
9
- ruby2.5 \
10
- ruby2.5-dev \
11
- build-essential \
12
- git
13
-
14
- RUN gem install --no-document \
15
- bundler \
16
- omnibus
17
-
18
- COPY Gemfile /
19
- RUN bundle install
20
-
21
- WORKDIR /omnibus-ridgepole
@@ -1,24 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Install omnibus
4
- gem 'omnibus', '~> 6.0'
5
- gem 'omnibus-software', git: 'https://github.com/chef/omnibus-software.git'
6
-
7
- gem 'rake'
8
-
9
- # Use Chef's software definitions. It is recommended that you write your own
10
- # software definitions, but you can clone/fork Chef's to get you started.
11
- # gem 'omnibus-software', github: 'chef/omnibus-software'
12
-
13
- # This development group is installed by default when you run `bundle install`,
14
- # but if you are using Omnibus in a CI-based infrastructure, you do not need
15
- # the Test Kitchen-based build lab. You can skip these unnecessary dependencies
16
- # by running `bundle install --without development` to speed up build times.
17
- group :development do
18
- # Use Berkshelf for resolving cookbook dependencies
19
- gem 'berkshelf', '~> 3.3'
20
-
21
- # Use Test Kitchen with Vagrant for converging the build environment
22
- gem 'test-kitchen', '~> 1.4'
23
- gem 'kitchen-vagrant', '~> 0.18'
24
- end
@@ -1,15 +0,0 @@
1
- omnibus-ridgepole
2
- -----------------
3
-
4
- ## Installation
5
-
6
- ```sh
7
- bundle install
8
- bundle exec rake docker:image:build
9
- ```
10
-
11
- ## Build omnibus-ridgepole
12
-
13
- ```sh
14
- bundle exec rake omnibus:build
15
- ```
@@ -1,38 +0,0 @@
1
- DOCKER_IMAGE_UBUNTU = 'omnibus-ridgepole-ubuntu'
2
- DOCKER_IMAGE_CENTOS = 'omnibus-ridgepole-chentos'
3
-
4
- namespace :docker do
5
- namespace :image do
6
- task build: ['build:ubuntu', 'build:centos']
7
-
8
- namespace :build do
9
- task :ubuntu do
10
- sh 'docker', 'build', '-t', DOCKER_IMAGE_UBUNTU, '-f', 'Dockerfile.ubuntu', '.'
11
- end
12
-
13
- task :centos do
14
- sh 'docker', 'build', '-t', DOCKER_IMAGE_CENTOS, '-f', 'Dockerfile.centos', '.'
15
- end
16
- end
17
- end
18
-
19
- namespace :omnibus do
20
- task :build do
21
- sh 'omnibus', 'build', 'ridgepole'
22
- end
23
- end
24
- end
25
-
26
- namespace :omnibus do
27
- task build: ['docker:image:build', 'build:ubuntu', 'build:centos']
28
-
29
- namespace :build do
30
- task :ubuntu do
31
- sh 'docker', 'run', '-v', "#{pwd}:/omnibus-ridgepole", DOCKER_IMAGE_UBUNTU, 'bundle', 'exec', 'rake docker:omnibus:build'
32
- end
33
-
34
- task :centos do
35
- sh 'docker', 'run', '-v', "#{pwd}:/omnibus-ridgepole", DOCKER_IMAGE_CENTOS, 'bundle', 'exec', 'rake docker:omnibus:build'
36
- end
37
- end
38
- end
@@ -1,27 +0,0 @@
1
- require 'json'
2
- require 'open-uri'
3
-
4
- name 'ridgepole'
5
- maintainer 'winebarrel <sugawara@winebarrel.jp>'
6
- homepage 'https://github.com/winebarrel/ridgepole'
7
-
8
- # Defaults to C:/ridgepole on Windows
9
- # and /opt/ridgepole on all other platforms
10
- install_dir "#{default_root}/#{name}"
11
-
12
- build_version JSON.parse(open('https://rubygems.org/api/v1/gems/ridgepole.json', &:read)).fetch('version')
13
- build_iteration 1
14
-
15
- dependency 'preparation'
16
-
17
- # ridgepole dependencies/components
18
- override :ruby, version: '2.5.1'
19
- dependency 'ruby'
20
- dependency 'rubygems'
21
- dependency 'ridgepole'
22
-
23
- # Version manifest file
24
- dependency 'version-manifest'
25
-
26
- exclude '**/.git'
27
- exclude '**/bundler/git'
@@ -1,13 +0,0 @@
1
- require 'json'
2
- require 'open-uri'
3
-
4
- name 'ridgepole'
5
-
6
- default_version JSON.parse(open('https://rubygems.org/api/v1/gems/ridgepole.json', &:read)).fetch('version')
7
-
8
- license 'MIT'
9
- skip_transitive_dependency_licensing true
10
-
11
- build do
12
- gem 'install ridgepole -N'
13
- end
@@ -1,54 +0,0 @@
1
- #
2
- # This file is used to configure the ridgepole project. It contains
3
- # some minimal configuration examples for working with Omnibus. For a full list
4
- # of configurable options, please see the documentation for +omnibus/config.rb+.
5
- #
6
-
7
- # Build internally
8
- # ------------------------------
9
- # By default, Omnibus uses system folders (like +/var+ and +/opt+) to build and
10
- # cache components. If you would to build everything internally, you can
11
- # uncomment the following options. This will prevent the need for root
12
- # permissions in most cases.
13
- #
14
- # Uncomment this line to change the default base directory to "local"
15
- # -------------------------------------------------------------------
16
- # base_dir './local'
17
- #
18
- # Alternatively you can tune the individual values
19
- # ------------------------------------------------
20
- # cache_dir './local/omnibus/cache'
21
- # git_cache_dir './local/omnibus/cache/git_cache'
22
- # source_dir './local/omnibus/src'
23
- # build_dir './local/omnibus/build'
24
- # package_dir './local/omnibus/pkg'
25
- # package_tmp './local/omnibus/pkg-tmp'
26
-
27
- # Disable git caching
28
- # ------------------------------
29
- # use_git_caching false
30
-
31
- # Enable S3 asset caching
32
- # ------------------------------
33
- # use_s3_caching true
34
- # s3_access_key ENV['AWS_ACCESS_KEY_ID']
35
- # s3_secret_key ENV['AWS_SECRET_ACCESS_KEY']
36
- # s3_profile ENV['AWS_S3_PROFILE']
37
- # s3_bucket ENV['AWS_S3_BUCKET']
38
-
39
- # Customize compiler bits
40
- # ------------------------------
41
- # solaris_compiler 'gcc'
42
- # build_retries 5
43
- # fetcher_read_timeout 120
44
- # fetcher_retries 5
45
-
46
- # Load additional software
47
- # ------------------------------
48
- # software_gems ['omnibus-software', 'my-company-software']
49
- # local_software_dirs ['/path/to/local/software']
50
-
51
- # Windows architecture defaults
52
- # ------------------------------
53
- windows_arch %w{x86 x64}.include?((ENV['OMNIBUS_WINDOWS_ARCH'] || '').downcase) ?
54
- ENV['OMNIBUS_WINDOWS_ARCH'].downcase.to_sym : :x86
@@ -1 +0,0 @@
1
- ln -sf /opt/ridgepole/embedded/bin/ridgepole /usr/bin
@@ -1 +0,0 @@
1
- rm -f /usr/bin/ridgepole
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client (with bigint pk)', condition: 5.0 do
4
- let(:id_primary_key_create_table) do
5
- <<-RUBY
6
- create_table "books", id: :primary_key, limit: 8, force: :cascade do |t|
7
- t.string "title", null: false
8
- t.integer "author_id", null: false
9
- t.datetime "created_at"
10
- t.datetime "updated_at"
11
- end
12
- RUBY
13
- end
14
-
15
- let(:id_bigint_create_table) do
16
- <<-RUBY
17
- create_table "books", id: :bigint, force: :cascade do |t|
18
- t.string "title", null: false
19
- t.integer "author_id", null: false
20
- t.datetime "created_at"
21
- t.datetime "updated_at"
22
- end
23
- RUBY
24
- end
25
-
26
- context 'when with limit:8' do
27
- subject { client }
28
-
29
- before { subject.diff(id_primary_key_create_table).migrate }
30
-
31
- it {
32
- expect(show_create_table(:books)).to include '`id` bigint(20) NOT NULL AUTO_INCREMENT'
33
- expect(subject.dump).to match_fuzzy id_bigint_create_table
34
- }
35
- end
36
-
37
- context 'when with id:bigint' do
38
- subject { client }
39
-
40
- before { subject.diff(id_bigint_create_table).migrate }
41
-
42
- it {
43
- expect(show_create_table(:books)).to include '`id` bigint(20) NOT NULL AUTO_INCREMENT'
44
- expect(subject.dump).to match_fuzzy id_bigint_create_table
45
- }
46
- end
47
- end
@@ -1,141 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when create index' do
5
- let(:dsl) do
6
- erbh(<<-ERB)
7
- create_table "clubs", force: :cascade do |t|
8
- t.string "name", default: "", null: false
9
- t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
10
- end
11
-
12
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
13
- t.string "dept_name", limit: 40, null: false
14
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
15
- end
16
-
17
- create_table "dept_emp", id: false, force: :cascade do |t|
18
- t.integer "emp_no", null: false
19
- t.string "dept_no", null: false
20
- t.date "from_date", null: false
21
- t.date "to_date", null: false
22
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
23
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
24
- end
25
-
26
- create_table "dept_manager", id: false, force: :cascade do |t|
27
- t.string "dept_no", null: false
28
- t.integer "emp_no", null: false
29
- t.date "from_date", null: false
30
- t.date "to_date", null: false
31
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
32
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
33
- end
34
-
35
- create_table "employee_clubs", force: :cascade do |t|
36
- t.integer "emp_no", null: false
37
- t.integer "club_id", null: false
38
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
39
- end
40
-
41
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
42
- t.date "birth_date", null: false
43
- t.string "first_name", limit: 14, null: false
44
- t.string "last_name", limit: 16, null: false
45
- t.string "gender", limit: 1, null: false
46
- t.date "hire_date", null: false
47
- end
48
-
49
- create_table "salaries", id: false, force: :cascade do |t|
50
- t.integer "emp_no", null: false
51
- t.integer "salary", null: false
52
- t.date "from_date", null: false
53
- t.date "to_date", null: false
54
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
55
- end
56
-
57
- create_table "titles", id: false, force: :cascade do |t|
58
- t.integer "emp_no", null: false
59
- t.string "title", limit: 50, null: false
60
- t.date "from_date", null: false
61
- t.date "to_date"
62
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
63
- end
64
- ERB
65
- end
66
-
67
- let(:actual_dsl) do
68
- erbh(<<-ERB)
69
- create_table "clubs", force: :cascade do |t|
70
- t.string "name", default: "", null: false
71
- end
72
-
73
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
74
- t.string "dept_name", limit: 40, null: false
75
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
76
- end
77
-
78
- create_table "dept_emp", id: false, force: :cascade do |t|
79
- t.integer "emp_no", null: false
80
- t.string "dept_no", null: false
81
- t.date "from_date", null: false
82
- t.date "to_date", null: false
83
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
84
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
85
- end
86
-
87
- create_table "dept_manager", id: false, force: :cascade do |t|
88
- t.string "dept_no", null: false
89
- t.integer "emp_no", null: false
90
- t.date "from_date", null: false
91
- t.date "to_date", null: false
92
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
93
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
94
- end
95
-
96
- create_table "employee_clubs", force: :cascade do |t|
97
- t.integer "emp_no", null: false
98
- t.integer "club_id", null: false
99
- end
100
-
101
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
102
- t.date "birth_date", null: false
103
- t.string "first_name", limit: 14, null: false
104
- t.string "last_name", limit: 16, null: false
105
- t.string "gender", limit: 1, null: false
106
- t.date "hire_date", null: false
107
- end
108
-
109
- create_table "salaries", id: false, force: :cascade do |t|
110
- t.integer "emp_no", null: false
111
- t.integer "salary", null: false
112
- t.date "from_date", null: false
113
- t.date "to_date", null: false
114
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
115
- end
116
-
117
- create_table "titles", id: false, force: :cascade do |t|
118
- t.integer "emp_no", null: false
119
- t.string "title", limit: 50, null: false
120
- t.date "from_date", null: false
121
- t.date "to_date"
122
- end
123
- ERB
124
- end
125
-
126
- let(:expected_dsl) { dsl }
127
-
128
- before { subject.diff(actual_dsl).migrate }
129
- subject { client(mysql_use_alter: true) }
130
-
131
- it {
132
- delta = subject.diff(expected_dsl)
133
- expect(delta.differ?).to be_truthy
134
- expect(subject.dump).to match_ruby actual_dsl
135
- _migrated, sql = delta.migrate(noop: true)
136
- expect(sql).to match(/ALTER/)
137
- delta.migrate
138
- expect(subject.dump).to match_ruby expected_dsl
139
- }
140
- end
141
- end
@@ -1,141 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when drop index' do
5
- let(:dsl) do
6
- erbh(<<-ERB)
7
- create_table "clubs", force: :cascade do |t|
8
- t.string "name", default: "", null: false
9
- t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
10
- end
11
-
12
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
13
- t.string "dept_name", limit: 40, null: false
14
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
15
- end
16
-
17
- create_table "dept_emp", id: false, force: :cascade do |t|
18
- t.integer "emp_no", null: false
19
- t.string "dept_no", null: false
20
- t.date "from_date", null: false
21
- t.date "to_date", null: false
22
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
23
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
24
- end
25
-
26
- create_table "dept_manager", id: false, force: :cascade do |t|
27
- t.string "dept_no", null: false
28
- t.integer "emp_no", null: false
29
- t.date "from_date", null: false
30
- t.date "to_date", null: false
31
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
32
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
33
- end
34
-
35
- create_table "employee_clubs", force: :cascade do |t|
36
- t.integer "emp_no", null: false
37
- t.integer "club_id", null: false
38
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
39
- end
40
-
41
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
42
- t.date "birth_date", null: false
43
- t.string "first_name", limit: 14, null: false
44
- t.string "last_name", limit: 16, null: false
45
- t.string "gender", limit: 1, null: false
46
- t.date "hire_date", null: false
47
- end
48
-
49
- create_table "salaries", id: false, force: :cascade do |t|
50
- t.integer "emp_no", null: false
51
- t.integer "salary", null: false
52
- t.date "from_date", null: false
53
- t.date "to_date", null: false
54
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
55
- end
56
-
57
- create_table "titles", id: false, force: :cascade do |t|
58
- t.integer "emp_no", null: false
59
- t.string "title", limit: 50, null: false
60
- t.date "from_date", null: false
61
- t.date "to_date"
62
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
63
- end
64
- ERB
65
- end
66
-
67
- let(:actual_dsl) { dsl }
68
-
69
- let(:expected_dsl) do
70
- erbh(<<-ERB)
71
- create_table "clubs", force: :cascade do |t|
72
- t.string "name", default: "", null: false
73
- end
74
-
75
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
76
- t.string "dept_name", limit: 40, null: false
77
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
78
- end
79
-
80
- create_table "dept_emp", id: false, force: :cascade do |t|
81
- t.integer "emp_no", null: false
82
- t.string "dept_no", null: false
83
- t.date "from_date", null: false
84
- t.date "to_date", null: false
85
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
86
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
87
- end
88
-
89
- create_table "dept_manager", id: false, force: :cascade do |t|
90
- t.string "dept_no", null: false
91
- t.integer "emp_no", null: false
92
- t.date "from_date", null: false
93
- t.date "to_date", null: false
94
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
95
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
96
- end
97
-
98
- create_table "employee_clubs", force: :cascade do |t|
99
- t.integer "emp_no", null: false
100
- t.integer "club_id", null: false
101
- end
102
-
103
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
104
- t.date "birth_date", null: false
105
- t.string "first_name", limit: 14, null: false
106
- t.string "last_name", limit: 16, null: false
107
- t.string "gender", limit: 1, null: false
108
- t.date "hire_date", null: false
109
- end
110
-
111
- create_table "salaries", id: false, force: :cascade do |t|
112
- t.integer "emp_no", null: false
113
- t.integer "salary", null: false
114
- t.date "from_date", null: false
115
- t.date "to_date", null: false
116
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
117
- end
118
-
119
- create_table "titles", id: false, force: :cascade do |t|
120
- t.integer "emp_no", null: false
121
- t.string "title", limit: 50, null: false
122
- t.date "from_date", null: false
123
- t.date "to_date"
124
- end
125
- ERB
126
- end
127
-
128
- before { subject.diff(actual_dsl).migrate }
129
- subject { client(mysql_use_alter: true) }
130
-
131
- it {
132
- delta = subject.diff(expected_dsl)
133
- expect(delta.differ?).to be_truthy
134
- expect(subject.dump).to match_ruby actual_dsl
135
- _migrated, sql = delta.migrate(noop: true)
136
- expect(sql).to match(/ALTER/)
137
- delta.migrate
138
- expect(subject.dump).to match_ruby expected_dsl
139
- }
140
- end
141
- end