ghost_adapter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 16360adbdcaec4bfe137c537c3895a3d7ec75284f43711b17da3985874c337e1
4
+ data.tar.gz: 6eb5e12eab95103791e86ae42be79a40aed252b86ca802e683942ec0ee5d2396
5
+ SHA512:
6
+ metadata.gz: 206bede0e5fb5087a16b56fef1787060b072cd234e1101ba14c8d4b41efac55b15dcd43ce3a5d72dbcf0723c9d3d930a1042bbcd540d26b59459bdaa9fb7c585
7
+ data.tar.gz: 1edd7c6b056e355eabd320cabe30eec22699b1c0a91c8c12aff6ccaf348a5cfd130ab1e978d423e55c7c4f034658af8d9918ee15e4beeb8168d55e9b6d064822
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,29 @@
1
+ ## Description
2
+
3
+ Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4
+
5
+ Fixes # (issue)
6
+
7
+ ## Type of change
8
+
9
+ Please delete options that are not relevant.
10
+
11
+ - [ ] Bug fix (non-breaking change which fixes an issue)
12
+ - [ ] New feature (non-breaking change which adds functionality)
13
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14
+ - [ ] This change requires a documentation update
15
+
16
+ ## How Has This Been Tested?
17
+
18
+ Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
19
+
20
+ ## Checklist:
21
+
22
+ - [ ] My code follows the style guidelines set by rubocop
23
+ - [ ] I have performed a self-review of my own code
24
+ - [ ] I have made corresponding changes to the documentation
25
+ - [ ] My changes generate no new warnings
26
+ - [ ] I have added tests that prove my fix is effective or that my feature works
27
+ - [ ] New and existing unit tests pass locally with my changes
28
+ - [ ] Any dependent changes have been merged and published in downstream modules
29
+ - [ ] I have checked my code and corrected any misspellings
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /pkg/
6
+ /spec/reports/
7
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ Style/FrozenStringLiteralComment:
2
+ Enabled: false
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Style/RescueModifier:
8
+ Enabled: false
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - test/**/*_test.rb
13
+
14
+ Metrics/MethodLength:
15
+ IgnoredMethods:
16
+ - build_ghost_command
17
+ - mysql2_ghost_connection
18
+
19
+ Metrics/AbcSize:
20
+ IgnoredMethods:
21
+ - build_ghost_command
22
+ - mysql2_ghost_connection
23
+
24
+ Metrics/PerceivedComplexity:
25
+ IgnoredMethods:
26
+ - mysql2_ghost_connection
27
+
28
+ AllCops:
29
+ SuggestExtensions: false
30
+ TargetRubyVersion: 2.5
31
+ NewCops: enable
data/.travis.yml ADDED
@@ -0,0 +1,25 @@
1
+ language: ruby
2
+ rvm: 2.7
3
+
4
+ cache:
5
+ bundler: true
6
+
7
+ before_install:
8
+ - bundle install --jobs=3 --path=${BUNDLE_PATH:-vendor/bundle}
9
+
10
+ stages:
11
+ - name: Rubocop
12
+ if: type = pull_request OR branch = main
13
+ - name: Tests
14
+ if: type = pull_request OR branch = main
15
+
16
+ jobs:
17
+ include:
18
+ - stage: Rubocop
19
+ name: Run rubocop
20
+ script:
21
+ - bundle exec rake rubocop
22
+ - stage: Tests
23
+ name: Run minitest
24
+ script:
25
+ - bundle exec rake test
@@ -0,0 +1,5 @@
1
+ {
2
+ "solargraph.autoformat": true,
3
+ "solargraph.formatting": true
4
+
5
+ }
data/CODEOWNERS ADDED
@@ -0,0 +1,5 @@
1
+ # https://help.github.com/en/articles/about-code-owners
2
+ # These owners will be the default owners for everything in
3
+ # the repo. Unless a later match takes precedence, they
4
+ # will be requested for review when someone opens a PR.
5
+ * @acroos
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at austin.roos@wetransfer.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTORS.md ADDED
@@ -0,0 +1 @@
1
+ - @acroos (Austin C. Roos, austin.roos@wetransfer.com)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ghost_adapter.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ghost_adapter (0.0.2)
5
+ activerecord (>= 5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (6.1.1)
11
+ activesupport (= 6.1.1)
12
+ activerecord (6.1.1)
13
+ activemodel (= 6.1.1)
14
+ activesupport (= 6.1.1)
15
+ activesupport (6.1.1)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
21
+ ast (2.4.2)
22
+ bump (0.10.0)
23
+ concurrent-ruby (1.1.8)
24
+ i18n (1.8.8)
25
+ concurrent-ruby (~> 1.0)
26
+ minitest (5.14.3)
27
+ parallel (1.20.1)
28
+ parser (3.0.0.0)
29
+ ast (~> 2.4.1)
30
+ rainbow (3.0.0)
31
+ rake (13.0.3)
32
+ regexp_parser (2.0.3)
33
+ rexml (3.2.4)
34
+ rubocop (1.8.1)
35
+ parallel (~> 1.10)
36
+ parser (>= 3.0.0.0)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ regexp_parser (>= 1.8, < 3.0)
39
+ rexml
40
+ rubocop-ast (>= 1.2.0, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 1.4.0, < 3.0)
43
+ rubocop-ast (1.4.1)
44
+ parser (>= 2.7.1.5)
45
+ ruby-progressbar (1.11.0)
46
+ tzinfo (2.0.4)
47
+ concurrent-ruby (~> 1.0)
48
+ unicode-display_width (2.0.0)
49
+ zeitwerk (2.4.2)
50
+
51
+ PLATFORMS
52
+ ruby
53
+ x86_64-darwin-19
54
+
55
+ DEPENDENCIES
56
+ bump (~> 0)
57
+ bundler (~> 2)
58
+ ghost_adapter!
59
+ minitest (~> 5.14)
60
+ rake (~> 13.0)
61
+ rubocop (~> 1)
62
+
63
+ BUNDLED WITH
64
+ 2.2.6
data/LICENSE.md ADDED
@@ -0,0 +1,33 @@
1
+ Copyright 2021 WeTransfer
2
+
3
+ Hippocratic License Version Number: 2.1.
4
+
5
+ Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensor’s copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability.
6
+
7
+ Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensor’s rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensor’s copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions:
8
+
9
+ - Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor.
10
+
11
+ - Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) shall end immediately.
12
+
13
+ - Compliance with Human Rights Principles and Human Rights Laws.
14
+
15
+ 1. Human Rights Principles.
16
+
17
+ (a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles.
18
+
19
+ (b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise.
20
+
21
+ Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply.
22
+
23
+ 2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
24
+
25
+ 3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor’s reasonable attorneys’ fees, arising out of or relating to Licensee’s use of the Software in violation of Human Rights Laws or Human Rights Principles.
26
+
27
+ - Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee.
28
+
29
+ - Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
30
+
31
+ - Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
32
+
33
+ This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Ghost Adapter
2
+
3
+ ![ghost](./doc/images/ghost.png)
4
+
5
+ ![gem version](https://img.shields.io/gem/v/ghost_adapter)
6
+ ![travis](https://img.shields.io/travis/com/wetransfer/ghost_adapter)
7
+ ![Hippocratic License](https://img.shields.io/badge/license-Hippocratic-green?link=https://github.com/WeTransfer/ghost_adapter/blob/main/LICENSE.md)
8
+ ![gh-ost version](https://img.shields.io/badge/gh--ost%20version-1.1.0-blue?link=https://github.com/github/gh-ost/releases/latest)
9
+ ![depfu](https://img.shields.io/depfu/wetransfer/ghost_adapter)
10
+
11
+ A tiny, _very configurable_ ActiveRecord adapter built for running [gh-ost](https://github.com/github/gh-ost) migrations. When not running migrations, it'll stay the heck out of the way.
12
+
13
+ ## Installation
14
+
15
+ First, you'll need to install `gh-ost`. You can find the latest release [here](https://github.com/github/gh-ost/releases/latest). You can check the allowed version range in [the version checker](./lib/ghost_adapter/version_checker.rb#L13) (current range: [>= 1.1, < 2]). Once you've got that installed, install the gem!
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'ghost_adapter'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle install
26
+
27
+ ## Usage
28
+
29
+ ### Connect with ActiveRecord
30
+
31
+ Configure your ActiveRecord connection to use `mysql2_ghost` as the adapter in whichever environments you'd like to use `gh-ost`.
32
+
33
+ For a standard rails project, in `config/database.yml` set `adapter: mysql2_ghost`.
34
+
35
+ For usage with `DATABASE_URL`, only a _very tiny_ modification is necessary. The URL should be like: `mysql2-ghost://` (notice the `-` instead of `_`). This is because the scheme of a URI must either alphanumeric or one of [`-`, `.`, `+`] ([more details](https://tools.ietf.org/html/rfc3986#section-3.1))
36
+
37
+ ### Configuration
38
+
39
+ You can configure `ghost_adapter` with (nearly) all of the arguments allowed `gh-ost` in the command line. The arguments are up to date as of `gh-ost` version 1.1.0.
40
+
41
+ Read more about configuration methods in [the docs](./doc/configuration.md).
42
+
43
+ ### Running Migrations
44
+
45
+ Since most database activity isn't a migration, we default to identical behavior to the Mysql2Adapter. No need to be executing a bunch of extra logic per query when you're only getting any value for migrations.
46
+
47
+ To enable the ghost adapter, you have two options. First (recommended) is to use the provided rails generator:
48
+
49
+ ```shell
50
+ rails g ghost_adapter:install
51
+ ```
52
+
53
+ This does everything you need. All migrations will run through gh-ost and otherwise the adapter will be ignored.
54
+
55
+ Alternatively, you can enable (or disable) gh-ost migrations with an environment variable.
56
+
57
+ ```shell
58
+ GHOST_MIGRATE=1 rake db:...
59
+ ```
60
+
61
+ If you have used the rails generator, you can set the variable to a falsey value and it will override the behavior not to use gh-ost.
62
+
63
+ - "truthy" values: `[1, t, true, y, yes]`
64
+ - "falsey" values: `[0, f, false, n, no]`
65
+
66
+ ## Contributing
67
+
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wetransfer/ghost_adapter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](./CODE_OF_CONDUCT.md).
69
+ Please add your name to the [CONTRIBUTORS.md](./CONTRIBUTORS.md)
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [Hippocratic License](https://firstdonoharm.dev/version/2/1/license.html).
74
+
75
+ ## Code of Conduct
76
+
77
+ Everyone interacting in the Ghost Adapter project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](./CODE_OF_CONDUCT.md).
78
+
79
+ ---
80
+
81
+ Illustration by <a href="undefined">Icons 8</a> from <a href="https://icons8.com/">Icons8</a>
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ require 'rubocop/rake_task'
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'ghost_adapter'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,32 @@
1
+ require_relative 'lib/ghost_adapter/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'ghost_adapter'
5
+ spec.version = GhostAdapter::VERSION
6
+ spec.authors = ['Austin C Roos']
7
+ spec.email = ['austin.roos@wetransfer.com']
8
+
9
+ spec.summary = 'Run ActiveRecord migrations through gh-ost'
10
+ spec.description = spec.summary
11
+ spec.homepage = 'https://github.com/wetransfer/ghost_adapter'
12
+ spec.license = 'Hippocratic'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = spec.homepage
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|doc)/}) }
22
+ end
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_dependency 'activerecord', '>= 5'
26
+
27
+ spec.add_development_dependency 'bump', '~> 0'
28
+ spec.add_development_dependency 'bundler', '~> 2'
29
+ spec.add_development_dependency 'minitest', '~> 5.14'
30
+ spec.add_development_dependency 'rake', '~> 13.0'
31
+ spec.add_development_dependency 'rubocop', '~> 1'
32
+ end
@@ -0,0 +1,107 @@
1
+ require 'active_record/connection_adapters/mysql2_adapter'
2
+ require 'ghost_adapter/migrator'
3
+ require 'ghost_adapter/version_checker'
4
+
5
+ gem 'mysql2', '>= 0.4.4', '< 0.6.0'
6
+ require 'mysql2'
7
+
8
+ module ActiveRecord
9
+ module ConnectionHandling
10
+ # Establishes a connection to the database that's used by all Active Record objects.
11
+ def mysql2_ghost_connection(config)
12
+ config = config.symbolize_keys
13
+ config[:flags] ||= 0
14
+
15
+ if config[:flags].is_a? Array
16
+ config[:flags].push 'FOUND_ROWS'.freeze
17
+ else
18
+ config[:flags] |= Mysql2::Client::FOUND_ROWS
19
+ end
20
+
21
+ client = Mysql2::Client.new(config)
22
+ if GhostAdapter::Internal.ghost_migration_enabeld?
23
+ dry_run = ENV['DRY_RUN'] == '1'
24
+ GhostAdapter::VersionChecker.validate_executable! unless ENV['SKIP_GHOST_VERSION_CHECK'] == '1'
25
+ ConnectionAdapters::Mysql2GhostAdapter.new(client, logger, nil, config, dry_run: dry_run)
26
+ else
27
+ ConnectionAdapters::Mysql2Adapter.new(client, logger, nil, config)
28
+ end
29
+ rescue Mysql2::Error => e
30
+ raise ActiveRecord::NoDatabaseError if e.message.include?('Unknown database')
31
+
32
+ raise
33
+ end
34
+ end
35
+
36
+ module ConnectionAdapters
37
+ class Mysql2GhostAdapter < Mysql2Adapter
38
+ ADAPTER_NAME = 'mysql2_ghost'.freeze
39
+
40
+ def initialize(connection, logger, connection_options, config, dry_run: false)
41
+ super(connection, logger, connection_options, config)
42
+ @database = config[:database]
43
+ @dry_run = dry_run
44
+ end
45
+
46
+ def execute(sql, name = nil)
47
+ # Only ALTER TABLE statements are automatically skipped by gh-ost
48
+ # We need to manually skip CREATE TABLE, DROP TABLE, and
49
+ # INSERT/DELETE (to schema migrations) for dry runs
50
+ return if dry_run && should_skip_for_dry_run?(sql)
51
+
52
+ if (table, query = parse_sql(sql))
53
+ GhostAdapter::Migrator.execute(table, query, database, dry_run)
54
+ else
55
+ super(sql, name)
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ attr_reader :database, :dry_run
62
+
63
+ ALTER_TABLE_PATTERN = /\AALTER\s+TABLE\W*(?<table_name>\w+)\W*(?<query>.*)$/i.freeze
64
+ QUERY_ALLOWABLE_CHARS = /[^0-9a-z_\s():'"{}]/i.freeze
65
+ CREATE_TABLE_PATTERN = /\Acreate\stable/i.freeze
66
+ DROP_TABLE_PATTERN = /\Acreate\stable/i.freeze
67
+ INSERT_SCHEMA_MIGRATION_PATTERN = /\Ainsert\sinto\s`schema_migrations`/i.freeze
68
+ DROP_SCHEMA_MIGRATION_PATTERN = /\Adelete\sfrom\s`schema_migrations`/i.freeze
69
+
70
+ def parse_sql(sql)
71
+ capture = sql.match(ALTER_TABLE_PATTERN)
72
+ return if capture.nil?
73
+
74
+ captured_names = capture.names
75
+ return unless captured_names.include? 'table_name'
76
+ return unless captured_names.include? 'query'
77
+
78
+ [capture[:table_name], clean_query(capture[:query])]
79
+ end
80
+
81
+ def clean_query(query)
82
+ cleaned = query.gsub(QUERY_ALLOWABLE_CHARS, '')
83
+ cleaned.gsub('"', '\"')
84
+ end
85
+
86
+ def should_skip_for_dry_run?(sql)
87
+ if create_or_drop_table?(sql)
88
+ puts 'Skipping CREATE TABLE or DROP TABLE for dry run'
89
+ puts 'SQL:'
90
+ puts sql
91
+ end
92
+
93
+ create_or_drop_table?(sql) || schema_migration_update?(sql)
94
+ end
95
+
96
+ def create_or_drop_table?(sql)
97
+ CREATE_TABLE_PATTERN =~ sql ||
98
+ DROP_TABLE_PATTERN =~ sql
99
+ end
100
+
101
+ def schema_migration_update?(sql)
102
+ INSERT_SCHEMA_MIGRATION_PATTERN =~ sql ||
103
+ DROP_SCHEMA_MIGRATION_PATTERN =~ sql
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,12 @@
1
+ module GhostAdapter
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc 'Copy ghost_adapter_setup rakefile for automatic ghost migration'
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def copy_task
8
+ template 'ghost_adapter_setup.rake', 'lib/tasks/ghost_adapter_setup.rake'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ require 'ghost_adapter'
2
+
3
+ # Enable ghost_adapter for all rake migrations
4
+ GhostAdapter::Internal.load_task
@@ -0,0 +1,38 @@
1
+ require 'ghost_adapter/config'
2
+
3
+ require 'ghost_adapter/railtie' if defined? ::Rails::Railtie
4
+
5
+ module GhostAdapter
6
+ def self.config
7
+ @@config ||= GhostAdapter::Config.new # rubocop:disable Style/ClassVars
8
+ end
9
+
10
+ def self.setup(options = {})
11
+ @@config = GhostAdapter::Config.new(options) # rubocop:disable Style/ClassVars
12
+
13
+ yield @@config if block_given?
14
+ end
15
+
16
+ module Internal
17
+ @@ghost_migration_enabled = false # rubocop:disable Style/ClassVars
18
+
19
+ def self.load_task
20
+ return if @loaded
21
+
22
+ load File.join(File.dirname(__FILE__), 'tasks', 'ghost_adapter.rake')
23
+
24
+ @loaded = true
25
+ end
26
+
27
+ def self.enable_ghost_migration!
28
+ @@ghost_migration_enabled = true # rubocop:disable Style/ClassVars
29
+ end
30
+
31
+ def self.ghost_migration_enabeld?
32
+ env_val = ENV['GHOST_MIGRATE']&.downcase
33
+ return false if %w[0 n no f false].include?(env_val)
34
+
35
+ !!@@ghost_migration_enabled || %w[1 y yes t true].include?(env_val)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,44 @@
1
+ module GhostAdapter
2
+ class Command
3
+ def initialize(alter:, table:, database: nil, dry_run: false)
4
+ @alter = alter
5
+ @table = table
6
+ @database = GhostAdapter.config.database || database
7
+ @dry_run = dry_run
8
+ validate_args_and_config!
9
+ end
10
+
11
+ def to_a
12
+ [
13
+ EXECUTABLE,
14
+ *base_args,
15
+ *GhostAdapter.config.as_args,
16
+ *execute_arg
17
+ ]
18
+ end
19
+
20
+ private
21
+
22
+ EXECUTABLE = 'gh-ost'.freeze
23
+
24
+ attr_reader :alter, :database, :table, :dry_run
25
+
26
+ def validate_args_and_config!
27
+ raise ArgumentError, 'alter cannot be nil' if alter.nil?
28
+ raise ArgumentError, 'table cannot be nil' if table.nil?
29
+ raise ArgumentError, 'database cannot be nil' if database.nil?
30
+ end
31
+
32
+ def base_args
33
+ [
34
+ "--alter=#{alter}",
35
+ "--table=#{table}",
36
+ "--database=#{database}"
37
+ ]
38
+ end
39
+
40
+ def execute_arg
41
+ dry_run ? [] : ['--execute']
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,104 @@
1
+ require 'ghost_adapter/env_parser'
2
+
3
+ module GhostAdapter
4
+ CONFIG_KEYS = %i[aliyun_rds
5
+ allow_master_master
6
+ allow_nullable_unique_key
7
+ allow_on_master
8
+ approve_renamed_columns
9
+ assume_master_host
10
+ assume_rbr
11
+ check_flag
12
+ chunk_size
13
+ concurrent_rowcount
14
+ conf
15
+ critical_load
16
+ critical_load_hibernate_seconds
17
+ critical_load_interval_millis
18
+ cut_over
19
+ cut_over_exponential_backoff
20
+ cut_over_lock_timeout_seconds
21
+ database
22
+ debug
23
+ default_retries
24
+ discard_foreign_keys
25
+ dml_batch_size
26
+ exact_rowcount
27
+ exponential_backoff_max_interval
28
+ force_named_cut_over
29
+ force_named_panic
30
+ force_table_names
31
+ gcp
32
+ heartbeat_interval_millis
33
+ hooks_hint
34
+ hooks_hint_owner
35
+ hooks_hint_token
36
+ hooks_path
37
+ host
38
+ ignore_http_errors
39
+ initially_drop_ghost_table
40
+ initially_drop_old_table
41
+ initially_drop_socket_file
42
+ master_password
43
+ master_user
44
+ max_lag_millis
45
+ max_load
46
+ migrate_on_replica
47
+ mysql_timeout
48
+ nice_ratio
49
+ ok_to_drop_table
50
+ panic_flag_file
51
+ password
52
+ port
53
+ postpone_cut_over_flag_file
54
+ quiet
55
+ replica_server_id
56
+ replication_lag_query
57
+ serve_socket_file
58
+ serve_tcp_port
59
+ skip_foreign_key_checks
60
+ skip_renamed_columns
61
+ skip_strict_mode
62
+ ssl
63
+ ssl_allow_insecure
64
+ ssl_ca
65
+ ssl_cert
66
+ ssl_key
67
+ stack
68
+ switch_to_rbr
69
+ test_on_replica
70
+ test_on_replica_skip_replica_stop
71
+ throttle_additional_flag_file
72
+ throttle_control_replicas
73
+ throttle_flag_file
74
+ throttle_http
75
+ throttle_query
76
+ timestamp_old_table
77
+ tungsten
78
+ user
79
+ verbose].freeze
80
+ Config = Struct.new(*CONFIG_KEYS, keyword_init: true) do
81
+ def initialize(options = {})
82
+ env_config = EnvParser.new(ENV).config
83
+ config_options = options.merge(env_config)
84
+ super(config_options)
85
+ end
86
+
87
+ def compact
88
+ to_h.compact
89
+ end
90
+
91
+ def as_args
92
+ compact.map do |key, value|
93
+ next unless value # Skip both false and null values
94
+
95
+ hyphenated_key = key.to_s.gsub('_', '-')
96
+ if value == true
97
+ "--#{hyphenated_key}"
98
+ else
99
+ "--#{hyphenated_key}=#{value}"
100
+ end
101
+ end.compact
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,57 @@
1
+ module GhostAdapter
2
+ class EnvParser
3
+ attr_reader :config
4
+
5
+ def initialize(env = {})
6
+ @config = env.map do |key, value|
7
+ next unless ghost_key?(key)
8
+
9
+ config_key = convert_env_key(key)
10
+ config_value = convert_env_value(value)
11
+
12
+ [config_key, config_value]
13
+ end.compact.to_h
14
+ end
15
+
16
+ private
17
+
18
+ def ghost_key?(key)
19
+ key.start_with?('GHOST_') && (key != 'GHOST_MIGRATE')
20
+ end
21
+
22
+ def convert_env_key(key)
23
+ key.gsub('GHOST_', '').downcase
24
+ end
25
+
26
+ def convert_env_value(value)
27
+ num_val = try_to_i_env(value) || try_to_f_env(value)
28
+ return num_val unless num_val.nil?
29
+
30
+ bool_val = try_to_bool_env(value)
31
+ return bool_val unless bool_val.nil?
32
+
33
+ value
34
+ end
35
+
36
+ def try_to_i_env(value)
37
+ return unless /\A[0-9]+$/ =~ value
38
+
39
+ value.to_i
40
+ end
41
+
42
+ def try_to_f_env(value)
43
+ return unless /\A[0-9]*\.[0-9]+$/ =~ value
44
+
45
+ value.to_f
46
+ end
47
+
48
+ def try_to_bool_env(value)
49
+ lowered = value.downcase
50
+ return true if %w[yes y true t].include? lowered
51
+
52
+ return false if %w[no n false f].include? lowered
53
+
54
+ nil
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,26 @@
1
+ require 'ghost_adapter/command'
2
+
3
+ module GhostAdapter
4
+ class MigrationError < StandardError
5
+ def initialize(exit_code)
6
+ super("gh-ost migration failed. exit code: #{exit_code}")
7
+ end
8
+ end
9
+
10
+ class Migrator
11
+ def self.execute(table, query, database, dry_run)
12
+ command = GhostAdapter::Command.new(
13
+ alter: query, table: table, database: database, dry_run: dry_run
14
+ )
15
+ Open3.popen2e(*command.to_a) do |_stdin, stdout_stderr, wait_thread|
16
+ stdout_stderr.each_line do |line|
17
+ puts "[gh-ost]:\t\t#{line}"
18
+ end
19
+
20
+ raise MigrationError, wait_thread.value.exitstatus unless wait_thread.value.success?
21
+ end
22
+ # A little buffer time in case of consecutive alter table commands
23
+ sleep 5
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ require 'rails'
2
+
3
+ module GhostAdapter
4
+ class Railtie < Rails::Railtie
5
+ config.ghost_adapter = ActiveSupport::OrderedOptions.new
6
+
7
+ initializer 'ghost_adapter.configure' do |app|
8
+ GhostAdapter.setup(app.config.ghost_adapter.to_h)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module GhostAdapter
2
+ VERSION = '0.0.2'.freeze
3
+ end
@@ -0,0 +1,35 @@
1
+ module GhostAdapter
2
+ class IncompatibleVersion < StandardError
3
+ def initialize(version = nil)
4
+ message = %(
5
+ #{version.nil? ? 'gh-ost not installed' : "gh-ost incompatible version #{version} installed."}
6
+ please install version: [#{VersionChecker::ALLOWED_RANGE}]
7
+ for latest release, visit: https://github.com/github/gh-ost/releases/latest)
8
+ super(message)
9
+ end
10
+ end
11
+
12
+ class VersionChecker
13
+ ALLOWED_RANGE = Gem::Requirement.new('>= 1.1.0', '< 2')
14
+
15
+ class << self
16
+ def validate_executable!
17
+ found_version = fetch_version
18
+ raise IncompatibleVersion, found_version unless ALLOWED_RANGE.satisfied_by? found_version
19
+ end
20
+
21
+ private
22
+
23
+ def fetch_version
24
+ stdout, status = Open3.capture2('gh-ost', '--version')
25
+ raise IncompatibleVersion unless status.success?
26
+
27
+ begin
28
+ Gem::Version.new(stdout)
29
+ rescue ArgumentError
30
+ raise IncompatibleVersion
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ migration_tasks = %w[db:migrate db:migrate:up db:migrate:down db:migrate:reset db:migrate:redo db:rollback]
2
+
3
+ # Rails 6 supports multi-database setups
4
+ if defined?(Rails::Application) && Rails.version.split('.').first.to_i >= 6
5
+ require 'active_record'
6
+
7
+ databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
8
+
9
+ # the db:migrate tasks each have a separate command for migrating a single database
10
+ ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |spec_name|
11
+ migration_tasks.concat(%w[db:migrate db:migrate:up db:migrate:down].map { |task| "#{task}:#{spec_name}" })
12
+ end
13
+ end
14
+
15
+ migration_tasks.each do |task|
16
+ Rake::Task[task].enhance([:ghost_adapter_exec])
17
+ end
18
+
19
+ task ghost_adapter_exec: :environment do
20
+ GhostAdapter::Internal.enable_ghost_migration!
21
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ghost_adapter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Austin C Roos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-04 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: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bump
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '13.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '13.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1'
97
+ description: Run ActiveRecord migrations through gh-ost
98
+ email:
99
+ - austin.roos@wetransfer.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
105
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
106
+ - ".github/PULL_REQUEST_TEMPLATE.md"
107
+ - ".gitignore"
108
+ - ".rubocop.yml"
109
+ - ".travis.yml"
110
+ - ".vscode/settings.json"
111
+ - CODEOWNERS
112
+ - CODE_OF_CONDUCT.md
113
+ - CONTRIBUTORS.md
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - LICENSE.md
117
+ - README.md
118
+ - Rakefile
119
+ - bin/console
120
+ - ghost_adapter.gemspec
121
+ - lib/active_record/connection_adapters/mysql2_ghost_adapter.rb
122
+ - lib/generators/ghost_adapter/install_generator.rb
123
+ - lib/generators/ghost_adapter/templates/ghost_adapter_setup.rake
124
+ - lib/ghost_adapter.rb
125
+ - lib/ghost_adapter/command.rb
126
+ - lib/ghost_adapter/config.rb
127
+ - lib/ghost_adapter/env_parser.rb
128
+ - lib/ghost_adapter/migrator.rb
129
+ - lib/ghost_adapter/railtie.rb
130
+ - lib/ghost_adapter/version.rb
131
+ - lib/ghost_adapter/version_checker.rb
132
+ - lib/tasks/ghost_adapter.rake
133
+ homepage: https://github.com/wetransfer/ghost_adapter
134
+ licenses:
135
+ - Hippocratic
136
+ metadata:
137
+ homepage_uri: https://github.com/wetransfer/ghost_adapter
138
+ source_code_uri: https://github.com/wetransfer/ghost_adapter
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 2.5.0
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubygems_version: 3.1.2
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Run ActiveRecord migrations through gh-ost
158
+ test_files: []