Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vitess-activerecord-migration

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vitess-activerecord-migration

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Vitess::Activerecord::Migration

vitess-activerecord-migration is a gem for integrating Vitess with ActiveRecord migrations.

Vitess::Activerecord::Migration provides tools to integrate Vitess with ActiveRecord migrations, allowing for seamless database schema changes in a Vitess environment.

Installation

gem 'vitess-activerecord-migration'

Usage

Create a config file under config/initializers.

# config/initializers/vitess_activerecord_migration.rb
ActiveRecord::Migration.prepend(Vitess::Activerecord::Migration)

The default ddl strategy is vitess with no options.

When you want to change the ddl strategy and its options for one shot, you can set them in the migration file.

def default_ddl_strategy
  "direct"
end
def change
  create_table :test_vitess_users do |t|
    t.string :name
  end
end

When you want to change the default ddl strategy and its options, you can override the following methods.

# lib/vitess/activerecord/app_migration.rb
module Vitess
  module Activerecord
    module AppMigration
      def default_ddl_strategy
        "vitess --prefer-instant-ddl"
      end
    end
  end
end
# config/initializers/vitess_activerecord_migration.rb
require 'vitess/activerecord/app_migration'
ActiveRecord::Migration.prepend(Vitess::Activerecord::Migration)
ActiveRecord::Migration.prepend(Vitess::Activerecord::AppMigration)

When you want to change the log parameters during the migration, you can override the following method.

# lib/vitess/activerecord/app_migration.rb
module Vitess
  module Activerecord
    module AppMigration
      def migration_log_columns
        %w[
          migration_uuid
          progress
          eta_seconds
        ]
      end
    end
  end
end

Development

After checking out the repo, run the following command to start related containers.

$ docker compose up

Then, you can run the following command to create a vitess cluster.

$ docker exec -it migration-endtoend /bin/bash
323e040cee42:/endtoend# make migration-test-setup

Finally, you can run the test suite to verify that the gem works correctly.

$ docker exec -it migration /bin/bash
root@0401705ea521:/migration# rake spec

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoheimuta/vitess-activerecord-migration. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

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.

FAQs

Package last updated on 15 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc