bard-rake 0.17.3 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1978125e4131ac3084b5cd880b944a8231b25a95b6bd3cedc900c0b76a2a195
4
- data.tar.gz: fe9a5f760df2d17c2c642b9f10a318088a268ecdf965f2e9f1ac535a38b346d3
3
+ metadata.gz: cef03634f53844e05848762de6241e42ccbf4ec3036c505f58e24dc3492826cf
4
+ data.tar.gz: c1ad30e5b5e7cb68593a07bb8d9ef0d87b3cc260a1f5aa79ae68bd6bc9de6101
5
5
  SHA512:
6
- metadata.gz: 2b89bb98206cc06580ec75022ce618b81ec63845628a0664b1a9e6a39af2f060b010c11fe76dc941e91d54c3728af18d2754e6562eaea939f7b8e875616becff
7
- data.tar.gz: ababeb5e7af1425ba785cf0723ea1a0c29d1209e7b7469888bfb7536de89e37005f85380a241070fa404aac9f2de4f890351a697a66d3c1959597bb71e3fab64
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", "~> 1.3"
24
+ spec.add_development_dependency "bundler"
24
25
  spec.add_development_dependency(%q<rspec>, [">= 1.2.9"])
25
26
  end
26
27
 
@@ -1,6 +1,6 @@
1
1
  module Bard
2
2
  module Rake
3
- VERSION = "0.17.3"
3
+ VERSION = "0.18.0"
4
4
  end
5
5
  end
6
6
 
@@ -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.17.3
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: 2020-01-17 00:00:00.000000000 Z
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: '1.3'
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: '1.3'
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.0.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.