vitess-activerecord-migration 0.1.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.
- checksums.yaml +7 -0
- data/.env +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Dockerfile +10 -0
- data/LICENSE.txt +21 -0
- data/Makefile +9 -0
- data/README.md +98 -0
- data/Rakefile +12 -0
- data/compose.ci.yml +14 -0
- data/compose.override.yml +18 -0
- data/compose.yml +32 -0
- data/lib/vitess/activerecord/migration/version.rb +9 -0
- data/lib/vitess/activerecord/migration.rb +146 -0
- data/sig/rails_support.rbs +34 -0
- data/sig/vitess/activerecord/migration.rbs +33 -0
- data/tmp/.keep +0 -0
- data/vitess-activerecord-migration.gemspec +40 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3eae6c9228eb8d3d5ebae767cef06ff65c89b073e6598bf690ddbd0907e995a0
|
4
|
+
data.tar.gz: bed613b3ec15ac973a5dabd1957e054d68b5d7adaefb0938af03fba3b7b2be6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf5fef0a1132c9cc35a7af3314b64da6669653813d90dc50ddb65018ecfa456dc2c25d1b234a8c9a66a7d8f0838b186a0fa281f05249ef58b15e25b084410085
|
7
|
+
data.tar.gz: 213b03855f9303882dd237db331a7b030f1dfe704d18b70895b71b7dffb120165ce012bb932016dc8ce2ce45e9f18d9722ad77b1b65d6c5acd44ae4e0cf1aec5
|
data/.env
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at yoheimuta@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Dockerfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Yohei Yoshimuta
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Vitess::Activerecord::Migration
|
2
|
+
|
3
|
+
vitess-activerecord-migration is a gem for integrating Vitess with ActiveRecord migrations.
|
4
|
+
|
5
|
+
Vitess::Activerecord::Migration provides tools to integrate Vitess with ActiveRecord migrations,
|
6
|
+
allowing for seamless database schema changes in a Vitess environment.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```
|
11
|
+
gem 'vitess-activerecord-migration'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Create a config file under config/initializers.
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# config/initializers/vitess_activerecord_migration.rb
|
20
|
+
ActiveRecord::Migration.prepend(Vitess::Activerecord::Migration)
|
21
|
+
```
|
22
|
+
|
23
|
+
The default ddl strategy is `vitess` with no options.
|
24
|
+
|
25
|
+
When you want to set the ddl strategy and its options for one shot, you can set them in the migration file.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
def default_ddl_strategy
|
29
|
+
"direct"
|
30
|
+
end
|
31
|
+
def change
|
32
|
+
create_table :test_vitess_users do |t|
|
33
|
+
t.string :name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
When you want to set the default ddl strategy and its options, you can override the following methods.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# lib/vitess/activerecord/app_migration.rb
|
42
|
+
module Vitess
|
43
|
+
module Activerecord
|
44
|
+
module AppMigration
|
45
|
+
def default_ddl_strategy
|
46
|
+
"vitess --prefer-instant-ddl"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# config/initializers/vitess_activerecord_migration.rb
|
55
|
+
require 'vitess/activerecord/app_migration'
|
56
|
+
ActiveRecord::Migration.prepend(Vitess::Activerecord::Migration)
|
57
|
+
ActiveRecord::Migration.prepend(Vitess::Activerecord::AppMigration)
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
After checking out the repo, run the following command to start related containers.
|
64
|
+
|
65
|
+
```bash
|
66
|
+
$ docker compose up
|
67
|
+
```
|
68
|
+
|
69
|
+
Then, you can run the following command to create a vitess cluster.
|
70
|
+
|
71
|
+
```bash
|
72
|
+
$ docker exec -it migration-endtoend /bin/bash
|
73
|
+
323e040cee42:/endtoend# make migration-test-setup
|
74
|
+
```
|
75
|
+
|
76
|
+
Finally, you can run the test suite to verify that the gem works correctly.
|
77
|
+
|
78
|
+
```bash
|
79
|
+
$ docker exec -it migration /bin/bash
|
80
|
+
root@0401705ea521:/migration# rake spec
|
81
|
+
```
|
82
|
+
|
83
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
84
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
85
|
+
which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yoheimuta/vitess-activerecord-migration.
|
90
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/vitess-activerecord-migration/blob/main/CODE_OF_CONDUCT.md).
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
95
|
+
|
96
|
+
## Code of Conduct
|
97
|
+
|
98
|
+
Everyone interacting in the Vitess::Activerecord::Migration project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/vitess-activerecord-migration/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/compose.ci.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
services:
|
2
|
+
migration:
|
3
|
+
command: bash -c "git config --global --add safe.directory /migration && bin/setup && rake spec"
|
4
|
+
depends_on:
|
5
|
+
migration-endtoend:
|
6
|
+
condition: service_healthy
|
7
|
+
migration-endtoend:
|
8
|
+
command: bash -c "dockerd-entrypoint.sh & sleep 5 && unset DOCKER_HOST && make migration-test-setup"
|
9
|
+
healthcheck:
|
10
|
+
test: ["CMD", "make", "keyspace-serving-check"]
|
11
|
+
interval: 10s
|
12
|
+
timeout: 10s
|
13
|
+
retries: 60
|
14
|
+
start_period: 1m
|
@@ -0,0 +1,18 @@
|
|
1
|
+
services:
|
2
|
+
migration:
|
3
|
+
command: bash -c "bin/setup && tail -f /dev/null"
|
4
|
+
migration-endtoend:
|
5
|
+
ports:
|
6
|
+
# http
|
7
|
+
- "53303:3303"
|
8
|
+
# mysql (vtgate)
|
9
|
+
- "53306:3306"
|
10
|
+
migration-mysql:
|
11
|
+
image: mysql:8.0
|
12
|
+
container_name: migration-mysql
|
13
|
+
ports:
|
14
|
+
- "18306:3306"
|
15
|
+
environment:
|
16
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
17
|
+
networks:
|
18
|
+
- migration-default
|
data/compose.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
services:
|
2
|
+
migration:
|
3
|
+
build:
|
4
|
+
context: .
|
5
|
+
args:
|
6
|
+
RUBY_VERSION: ${RUBY_VERSION}
|
7
|
+
RAILS_VERSION: ${RAILS_VERSION}
|
8
|
+
container_name: migration
|
9
|
+
volumes:
|
10
|
+
- bundle:/usr/local/bundle
|
11
|
+
- .:/migration
|
12
|
+
networks:
|
13
|
+
- migration-default
|
14
|
+
migration-endtoend:
|
15
|
+
build:
|
16
|
+
context: ./test/endtoend
|
17
|
+
args:
|
18
|
+
VITESS_VERSION: ${VITESS_VERSION}
|
19
|
+
container_name: migration-endtoend
|
20
|
+
privileged: true
|
21
|
+
volumes:
|
22
|
+
- .:/endtoend
|
23
|
+
- tmp:/endtoend/tmp
|
24
|
+
networks:
|
25
|
+
- migration-default
|
26
|
+
|
27
|
+
networks:
|
28
|
+
migration-default:
|
29
|
+
|
30
|
+
volumes:
|
31
|
+
bundle:
|
32
|
+
tmp:
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "migration/version"
|
4
|
+
require "active_record"
|
5
|
+
|
6
|
+
module Vitess
|
7
|
+
module Activerecord
|
8
|
+
module Migration
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
# Returns the default DDL strategy.
|
12
|
+
# This method is called and set before executing the change, up, or down methods.
|
13
|
+
#
|
14
|
+
# If you want to use a different strategy like `direct`, override this method.
|
15
|
+
def default_ddl_strategy
|
16
|
+
"vitess"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns the timeout seconds for waiting for the completion of the DDL statement.
|
20
|
+
# Even after the timeout, the migration on Vitess will not be stopped, but a warning will be logged.
|
21
|
+
#
|
22
|
+
# Override this method if you want to change the default timeout.
|
23
|
+
def wait_timeout_seconds
|
24
|
+
7200 # 120 minutes
|
25
|
+
end
|
26
|
+
|
27
|
+
# Override exec_migration to set the default DDL strategy to vitess.
|
28
|
+
# This method is called every time a migration is executed.
|
29
|
+
# If you want to use a different DDL strategy, call with_ddl_strategy inside the change method or elsewhere.
|
30
|
+
def exec_migration(connection, direction)
|
31
|
+
@migration_direction = direction
|
32
|
+
@using_change_method = self.respond_to?(:change)
|
33
|
+
@migration_context = "#{self.version}_#{self.class.name.underscore}"
|
34
|
+
with_ddl_strategy default_ddl_strategy do
|
35
|
+
super(connection, direction)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Override the create_table method.
|
40
|
+
# If using the Vitess strategy, wait for the completion of the CREATE TABLE statement.
|
41
|
+
# This prevents an evaluation error from occurring if you try to execute a DDL on that table before the creation is complete.
|
42
|
+
def create_table(table_name, **options)
|
43
|
+
super(table_name, **options)
|
44
|
+
|
45
|
+
# If create_table is called during revert, no additional processing is done.
|
46
|
+
# We expect the DROP statement to be issued automatically during revert, but if execute is run here,
|
47
|
+
# it will raise an IrreversibleMigration error, so this is to prevent that.
|
48
|
+
return if down_migration_in_change_method?
|
49
|
+
|
50
|
+
# If not using the Vitess strategy, do not wait for the completion of the CREATE TABLE statement.
|
51
|
+
return unless vitess_strategy?
|
52
|
+
|
53
|
+
wait_for_ddl
|
54
|
+
end
|
55
|
+
|
56
|
+
# Temporarily change the DDL strategy within the block.
|
57
|
+
#
|
58
|
+
# You can use this method inside the change method to change the strategy only during the execution of specific DDL statements.
|
59
|
+
# However, note that this makes the migration irreversible, so if it’s possible to handle this by overriding the default_ddl_strategy, use that instead.
|
60
|
+
def with_ddl_strategy(strategy)
|
61
|
+
if enable_vitess?
|
62
|
+
original_ddl_strategy = execute("SELECT @@ddl_strategy").first.first
|
63
|
+
execute("SET @@ddl_strategy='#{strategy}'")
|
64
|
+
execute("SET @@migration_context='#{@migration_context}'") unless strategy == "direct"
|
65
|
+
begin
|
66
|
+
yield
|
67
|
+
wait_for_ddl unless strategy == "direct"
|
68
|
+
ensure
|
69
|
+
execute("SET @@ddl_strategy='#{original_ddl_strategy}'")
|
70
|
+
end
|
71
|
+
else
|
72
|
+
yield
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def vitess_strategy?
|
79
|
+
enable_vitess? && execute("SELECT @@ddl_strategy").first.first.include?("vitess")
|
80
|
+
end
|
81
|
+
|
82
|
+
def down_migration_in_change_method?
|
83
|
+
@migration_direction == :down && @using_change_method
|
84
|
+
end
|
85
|
+
|
86
|
+
def enable_vitess?
|
87
|
+
version = execute("SELECT VERSION()").first.first
|
88
|
+
version.include?("Vitess")
|
89
|
+
end
|
90
|
+
|
91
|
+
def wait_for_ddl
|
92
|
+
start_time = Time.now
|
93
|
+
timeout_seconds = wait_timeout_seconds
|
94
|
+
interval_seconds = 2
|
95
|
+
max_interval_seconds = 30
|
96
|
+
|
97
|
+
@stopped_uuid ||= []
|
98
|
+
|
99
|
+
loop do
|
100
|
+
migrations = ActiveRecord::Base.connection.select_all("SHOW VITESS_MIGRATIONS LIKE '#{@migration_context}'")
|
101
|
+
|
102
|
+
migrations.each do |migration|
|
103
|
+
id = migration["id"]
|
104
|
+
next if @stopped_uuid.include?(id)
|
105
|
+
|
106
|
+
details = %w[migration_uuid migration_statement added_timestamp started_timestamp is_immediate_operation progress eta_seconds retries]
|
107
|
+
detail_message = details.map { |column| "#{column}: #{migration[column]}" }.join(" | ")
|
108
|
+
Rails.logger.info("Vitess Migration #{id} checking status, #{detail_message}")
|
109
|
+
|
110
|
+
status = migration["migration_status"]
|
111
|
+
if %(complete failed cancelled).include?(status)
|
112
|
+
case status
|
113
|
+
when "complete"
|
114
|
+
Rails.logger.info("Vitess Migration #{id} completed successfully at #{migration["completed_timestamp"]}")
|
115
|
+
when "failed"
|
116
|
+
Rails.logger.error("Vitess Migration #{id} failed: #{migration["message"]} at #{migration["completed_timestamp"]}")
|
117
|
+
when "cancelled"
|
118
|
+
Rails.logger.warn("Vitess Migration #{id} was cancelled at #{migration["cancelled_timestamp"]}")
|
119
|
+
end
|
120
|
+
@stopped_uuid << id
|
121
|
+
else
|
122
|
+
Rails.logger.info("Vitess Migration #{id} is still #{status}")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if @stopped_uuid.count == migrations.count
|
127
|
+
Rails.logger.info("Vitess Migration all completed successfully")
|
128
|
+
break
|
129
|
+
end
|
130
|
+
|
131
|
+
if Time.now - start_time > timeout_seconds
|
132
|
+
Rails.logger.warn("Vitess Migration did not complete within #{timeout_seconds} seconds. Timing out.")
|
133
|
+
break
|
134
|
+
end
|
135
|
+
|
136
|
+
Rails.logger.info("Waiting #{interval_seconds} seconds for Vitess DDL to complete...")
|
137
|
+
sleep(interval_seconds)
|
138
|
+
interval_seconds = [interval_seconds * 2, max_interval_seconds].min
|
139
|
+
end
|
140
|
+
rescue => e
|
141
|
+
Rails.logger.error("An error occurred while waiting for Vitess DDL: #{e.message}")
|
142
|
+
Rails.logger.error(e.backtrace.join("\n"))
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class RailsSupport
|
2
|
+
DATABASE_CONFIG: String
|
3
|
+
|
4
|
+
INIT_CONFIG: String
|
5
|
+
|
6
|
+
@migration_files: [String]
|
7
|
+
@rails_root: String
|
8
|
+
|
9
|
+
@schema_backup_path: String
|
10
|
+
|
11
|
+
@schema_path: String
|
12
|
+
|
13
|
+
def self.copy_template_file: (*String)-> void
|
14
|
+
|
15
|
+
def self.setup: -> void
|
16
|
+
|
17
|
+
def create_test_vitess_users: (String)->[String,String]
|
18
|
+
|
19
|
+
def generate_migration: -> String
|
20
|
+
|
21
|
+
def run: (String,String?)-> void
|
22
|
+
|
23
|
+
def run_test_env: (String)->void
|
24
|
+
|
25
|
+
def setup: -> void
|
26
|
+
|
27
|
+
def cleanup : -> void
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def db_config: ->untyped
|
32
|
+
|
33
|
+
def rails_new: -> void
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Vitess
|
2
|
+
module Activerecord
|
3
|
+
module Migration
|
4
|
+
VERSION: String
|
5
|
+
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
|
6
|
+
@migration_context: String
|
7
|
+
@migration_direction: Symbol
|
8
|
+
|
9
|
+
@stopped_uuid: [String]
|
10
|
+
@using_change_method: bool
|
11
|
+
|
12
|
+
def create_table: (String, untyped)->void
|
13
|
+
|
14
|
+
def default_ddl_strategy: -> String
|
15
|
+
|
16
|
+
def wait_timeout_seconds: -> Integer
|
17
|
+
|
18
|
+
def exec_migration: (untyped, Symbol)-> void
|
19
|
+
|
20
|
+
def with_ddl_strategy: (String)-> void
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def down_migration_in_change_method?: -> bool
|
25
|
+
|
26
|
+
def enable_vitess?: -> bool
|
27
|
+
|
28
|
+
def vitess_strategy?: -> bool
|
29
|
+
|
30
|
+
def wait_for_ddl: -> void
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/tmp/.keep
ADDED
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/vitess/activerecord/migration/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "vitess-activerecord-migration"
|
7
|
+
spec.version = Vitess::Activerecord::Migration::VERSION
|
8
|
+
spec.authors = ["Yohei Yoshimuta"]
|
9
|
+
spec.email = ["yoheimuta@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "A gem for integrating Vitess with ActiveRecord migrations."
|
12
|
+
spec.description = "Vitess::Activerecord::Migration provides tools to integrate Vitess with ActiveRecord migrations, allowing for seamless database schema changes in a Vitess environment."
|
13
|
+
spec.homepage = "https://github.com/yoheimuta/vitess-activerecord-migration"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/yoheimuta/vitess-activerecord-migration"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/yoheimuta/vitess-activerecord-migration/blob/main/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(File.expand_path(f) == __FILE__) ||
|
28
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
# Uncomment to register a new dependency of your gem
|
36
|
+
spec.add_dependency "activerecord", ">= 6", "< 8.1"
|
37
|
+
|
38
|
+
# For more information and examples about making a new gem, check out our
|
39
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vitess-activerecord-migration
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yohei Yoshimuta
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '8.1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '6'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '8.1'
|
33
|
+
description: Vitess::Activerecord::Migration provides tools to integrate Vitess with
|
34
|
+
ActiveRecord migrations, allowing for seamless database schema changes in a Vitess
|
35
|
+
environment.
|
36
|
+
email:
|
37
|
+
- yoheimuta@gmail.com
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- ".env"
|
43
|
+
- ".rspec"
|
44
|
+
- ".rubocop.yml"
|
45
|
+
- CHANGELOG.md
|
46
|
+
- CODE_OF_CONDUCT.md
|
47
|
+
- Dockerfile
|
48
|
+
- LICENSE.txt
|
49
|
+
- Makefile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- compose.ci.yml
|
53
|
+
- compose.override.yml
|
54
|
+
- compose.yml
|
55
|
+
- lib/vitess/activerecord/migration.rb
|
56
|
+
- lib/vitess/activerecord/migration/version.rb
|
57
|
+
- sig/rails_support.rbs
|
58
|
+
- sig/vitess/activerecord/migration.rbs
|
59
|
+
- tmp/.keep
|
60
|
+
- vitess-activerecord-migration.gemspec
|
61
|
+
homepage: https://github.com/yoheimuta/vitess-activerecord-migration
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata:
|
65
|
+
allowed_push_host: https://rubygems.org
|
66
|
+
homepage_uri: https://github.com/yoheimuta/vitess-activerecord-migration
|
67
|
+
source_code_uri: https://github.com/yoheimuta/vitess-activerecord-migration
|
68
|
+
changelog_uri: https://github.com/yoheimuta/vitess-activerecord-migration/blob/main/CHANGELOG.md
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.7.0
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.0.3.1
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: A gem for integrating Vitess with ActiveRecord migrations.
|
88
|
+
test_files: []
|