bard-rake 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bard-rake.gemspec +2 -1
- data/lib/bard/rake/db_dump_load.rb +1 -1
- data/lib/bard/rake/db_multiple_environment_sanity.rb +2 -10
- data/lib/bard/rake/version.rb +1 -1
- data/lib/generators/bard/utf8mb4_migration/templates/migration.rb.tt +40 -0
- data/lib/generators/bard/utf8mb4_migration/utf8mb4_migration_generator.rb +27 -0
- metadata +23 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cef03634f53844e05848762de6241e42ccbf4ec3036c505f58e24dc3492826cf
|
4
|
+
data.tar.gz: c1ad30e5b5e7cb68593a07bb8d9ef0d87b3cc260a1f5aa79ae68bd6bc9de6101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7136e73f23f0c82e3fe94467b29d958377825dce071e9293c7f5b24062d4ab2579d3f8abce59b67b2b5ef8ce64b1768eab82d5e764d426d7ee61e7a0b720c8ae
|
7
|
+
data.tar.gz: 8b55fa6283e4450ef582103d5f6ce299d25a8e8e158e7e84d5563b5e8dee74c001fa7562f45a613fce3c1834cd1cb30f78ec6d1fc3eb75e6ea034c0395f02f44
|
data/bard-rake.gemspec
CHANGED
@@ -19,8 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "rake"
|
21
21
|
spec.add_dependency "backhoe"
|
22
|
+
spec.add_dependency "railties"
|
22
23
|
|
23
|
-
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "bundler"
|
24
25
|
spec.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
25
26
|
end
|
26
27
|
|
@@ -63,12 +63,8 @@ if defined?(ActiveRecord)
|
|
63
63
|
next unless whitelist.include?(env)
|
64
64
|
next if modified_databases.include?(database)
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
block.call configuration, env
|
69
|
-
else
|
70
|
-
$stderr.puts "This task only modifies local databases. #{database} is on a remote host."
|
71
|
-
end
|
66
|
+
ActiveRecord::Base.establish_connection configuration
|
67
|
+
block.call configuration, env
|
72
68
|
|
73
69
|
modified_databases << database
|
74
70
|
end
|
@@ -76,10 +72,6 @@ if defined?(ActiveRecord)
|
|
76
72
|
Rake::Task["db:_dump"].invoke
|
77
73
|
end
|
78
74
|
|
79
|
-
def local_database?(configuration)
|
80
|
-
configuration["host"].blank? || LOCAL_HOSTS.include?(configuration["host"])
|
81
|
-
end
|
82
|
-
|
83
75
|
def test_environment?
|
84
76
|
rails_env == "test"
|
85
77
|
end
|
data/lib/bard/rake/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
2
|
+
def up
|
3
|
+
execute "ALTER DATABASE `#{db.current_database}` CHARACTER SET #{charset} COLLATE #{collation};"
|
4
|
+
db.tables.each do |table|
|
5
|
+
execute "ALTER TABLE `#{table}` ROW_FORMAT=DYNAMIC CHARACTER SET #{charset} COLLATE #{collation};"
|
6
|
+
|
7
|
+
db.columns(table).each do |column|
|
8
|
+
case column.sql_type
|
9
|
+
when /([a-z]*)text/i
|
10
|
+
default = (column.default.blank?) ? '' : "DEFAULT '#{column.default}'"
|
11
|
+
null = (column.null) ? '' : 'NOT NULL'
|
12
|
+
execute "ALTER TABLE `#{table}` MODIFY `#{column.name}` #{column.sql_type.upcase} CHARACTER SET #{charset} COLLATE #{collation} #{default} #{null};"
|
13
|
+
when /varchar\(([0-9]+)\)/i
|
14
|
+
sql_type = column.sql_type.upcase
|
15
|
+
default = (column.default.blank?) ? '' : "DEFAULT '#{column.default}'"
|
16
|
+
null = (column.null) ? '' : 'NOT NULL'
|
17
|
+
execute "ALTER TABLE `#{table}` MODIFY `#{column.name}` #{sql_type} CHARACTER SET #{charset} COLLATE #{collation} #{default} #{null};"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def down
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def charset
|
29
|
+
"utf8mb4"
|
30
|
+
end
|
31
|
+
|
32
|
+
def collation
|
33
|
+
"utf8mb4_general_ci"
|
34
|
+
end
|
35
|
+
|
36
|
+
def db
|
37
|
+
ActiveRecord::Base.connection
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Bard
|
4
|
+
class Utf8mb4MigrationGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
|
+
|
9
|
+
def self.next_migration_number(dirname)
|
10
|
+
next_migration_number = current_migration_number(dirname) + 1
|
11
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
12
|
+
end
|
13
|
+
|
14
|
+
def install_migration
|
15
|
+
migration_template "migration.rb", "db/migrate/convert_to_utf8mb4.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def specify_charset_and_collation_in_database_yml
|
19
|
+
["config/database.yml", "config/database.sample.yml"].each do |file|
|
20
|
+
[" collation: utf8mb4_general_ci\n", " charset: utf8mb4\n"].each do |line|
|
21
|
+
inject_into_file file, line, after: " socket: /var/run/mysqld/mysqld.sock\n"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bard-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,20 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,6 +107,8 @@ files:
|
|
93
107
|
- lib/bard/rake/railtie.rb
|
94
108
|
- lib/bard/rake/testing.rb
|
95
109
|
- lib/bard/rake/version.rb
|
110
|
+
- lib/generators/bard/utf8mb4_migration/templates/migration.rb.tt
|
111
|
+
- lib/generators/bard/utf8mb4_migration/utf8mb4_migration_generator.rb
|
96
112
|
homepage: http://github.com/botandrose/bard-rake
|
97
113
|
licenses:
|
98
114
|
- MIT
|
@@ -112,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
128
|
- !ruby/object:Gem::Version
|
113
129
|
version: '0'
|
114
130
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.2.3
|
116
132
|
signing_key:
|
117
133
|
specification_version: 4
|
118
134
|
summary: Rake tasks for all bard projects.
|