nishio-dens / convergence Goto Github PK
View Code? Open in Web Editor NEWConvergence is a pure-Ruby database schema migration tool
License: MIT License
Convergence is a pure-Ruby database schema migration tool
License: MIT License
I would like to use ssl connections to connect mysql server.
I think Convergence should support ssl options of mysql2 client.
I would like to use convergence for my rails application running on postgreSQL.
table/column was output as a character.
Change it to output as a symbol.
Before
$bin/convergence -c ./database.yml --export
create_table "scheduled_publishings" do |t|
t.int "id", primary_key: true, extra: "auto_increment"
t.int "creative_id"
t.datetime "launch_at"
t.datetime "created_at"
t.datetime "updated_at"
end
After
$bin/convergence -c ./database.yml --export
create_table :scheduled_publishings do |t|
t.int :id, primary_key: true, extra: :auto_increment
t.int :creative_id,
t.datetime :launch_at
t.datetime :created_at
t.datetime :updated_at
end
Before
$ bin/convergence -c ./database.yml --export
...
t.tinyint "status_id", default: false, limit: 1
After
$ bin/convergence -c ./database.yml --export
...
t.boolean "status_id", default: false
create_table :test do |t|
t.varchar :something, default: ""
end
to
create_table :test do |t|
t.varchar :something
end
does not work fine
$ bin/convergence -i test.rb -c config.yml --dump-rails-migration --filename testdump
output
#Filename: 20171225000000_testdump.rb
class TestDump < ActiveRecord::Migration[5.0]
def change
create_table :test do |t|
t.string :something, null: false, limit: 5000
t.timestamps null: false
end
end
end
If you use the same column in both a normal (or unique) index and a foreign key like this:
create_table :test do |t|
t.int :id, primary_key: true, extra: :auto_increment
t.int :another_id
t.date :date
t.int :some_value
t.index [:another_id, :date], unique: true
t.foreign_key :another_id, reference: :anothers, reference_column: :id
end
then convergence will fail from the second invocation on because it does not recognize the foreign key that is already present in the database. It always tries to create the foreign key.
Invalid Query Exception >>>
ALTER TABLE `test` ADD CONSTRAINT `test_another_id_fk` FOREIGN KEY (another_id) REFERENCES `anothers`(id);
<<<
/home/philipp/.gem/ruby/gems/convergence-0.1.2/lib/convergence/command/apply.rb:39:in `throw': uncaught throw #<Mysql2::Error: Duplicate foreign key constraint name 'test/test_another_id_fk'> (UncaughtThrowError)
from /home/philipp/.gem/ruby/gems/convergence-0.1.2/lib/convergence/command/apply.rb:39:in `rescue in block in execute_sql'
from /home/philipp/.gem/ruby/gems/convergence-0.1.2/lib/convergence/command/apply.rb:30:in `block in execute_sql'
from /home/philipp/.gem/ruby/gems/convergence-0.1.2/lib/convergence/command/apply.rb:27:in `each'
from /home/philipp/.gem/ruby/gems/convergence-0.1.2/lib/convergence/command/apply.rb:27:in `execute_sql'
from /home/philipp/.gem/ruby/gems/convergence-0.1.2/lib/convergence/command/apply.rb:15:in `execute'
from /home/philipp/.gem/ruby/gems/convergence-0.1.2/lib/convergence/command.rb:23:in `execute'
from /home/philipp/.gem/ruby/gems/convergence-0.1.2/bin/convergence:23:in `<top (required)>'
from /home/philipp/bin/convergence:23:in `load'
from /home/philipp/bin/convergence:23:in `<main>'
rake aborted!
Command failed with status (1): [bundle exec convergence -c /home/philipp/t...]
I got an error when using convergence with diff-lcs v1.4.2.
CREATE TABLE `test_tables` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `index_test_tables_on_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
create_table 'test_tables' do |t|
t.int :id, primary_key: true, extra: 'auto_increment'
t.varchar :name, limit: 100, null: true
t.varchar :email, null: true
t.datetime :created_at
t.datetime :updated_at
t.index :name
end
convergence apply example.schema -c database.yml
$ convergence apply example.schema -c database.yml
Traceback (most recent call last):
17: from /home/yujideveloper/.rbenv/versions/2.7.1/bin/convergence:23:in `<main>'
16: from /home/yujideveloper/.rbenv/versions/2.7.1/bin/convergence:23:in `load'
15: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/bin/convergence:6:in `<top (required)>'
14: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
13: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
12: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
11: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
10: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/cli.rb:24:in `apply'
9: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/command/apply.rb:13:in `execute'
8: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/command/apply.rb:38:in `execute_sql'
7: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/command/apply.rb:21:in `generate_sql'
6: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/diff.rb:12:in `diff'
5: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/diff.rb:49:in `scan_change_table'
4: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/diff.rb:49:in `each'
3: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/diff.rb:52:in `block in scan_change_table'
2: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/diff.rb:27:in `diff_table'
1: from /home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/diff.rb:103:in `scan_change_order_column'
/home/yujideveloper/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/convergence-1.0.3/lib/convergence/diff.rb:103:in `select': undefined method `adding?' for "+":String (NoMethodError)
bin/convergence -c config.yml -i schema.rb --safe-migration
if --safe-migration option is enabled, convergence cannot execute drop table query.
Convergence is not currently support SQLite.
The current implementation is depend on mysql, so i need a big fix to do it.
Hello.
When my repository try to upgrade ruby to 3.1, I encountered ArgumentError in convergence apply
.
According to ruby/psych#533, psych 4.x included a breaking change.
convergence/lib/convergence/config.rb
Line 48 in 0cfc4db
I think to use safe_load with newer options like aliases: true
fixes this error.
But, what we need to consider is that we may need to drop support for older ruby 2.5 and below which are not support this option.
(My folked repository's test work with 2.5, but ruby doc doesn't exist this options...)
I will create PR to fix this error.
Reproduction:
% ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin20]
% cat database.yml
adapter: mysql
database: example_database
host: 127.0.0.1
username: root
password:
% bundle exec convergence apply schema.rb -c database.yml
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
bundler: failed to load command: convergence (/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/bin/convergence)
ArgumentError: wrong number of arguments (given 4, expected 1)
/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/3.1.0/psych.rb:323:in `safe_load'
/Users/yysaki/ghq/github.com/yysaki/convergence/lib/convergence/config.rb:48:in `load'
/Users/yysaki/ghq/github.com/yysaki/convergence/lib/convergence/cli.rb:58:in `config'
/Users/yysaki/ghq/github.com/yysaki/convergence/lib/convergence/cli.rb:29:in `apply'
/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
/Users/yysaki/ghq/github.com/yysaki/convergence/bin/convergence:6:in `<top (required)>'
/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/bin/convergence:25:in `load'
/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/bin/convergence:25:in `<top (required)>'
When I migrate from a dev machine (with very high IDs after testing), this forces the production server to jump/skip thousands of useable auto-increment IDs to the latest one. Increment ID helps with data, but I only do schemas here.
Or did I miss something? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.