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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ff9efd86b5af9fe0cd76d0040ff9c8c1ee9f4ac44d6f734d2088208ecb540e8
4
- data.tar.gz: 3aa80505be2130df0af16819812d7c7585a7437732e0b9676ced2d1a993f40f6
3
+ metadata.gz: cef03634f53844e05848762de6241e42ccbf4ec3036c505f58e24dc3492826cf
4
+ data.tar.gz: c1ad30e5b5e7cb68593a07bb8d9ef0d87b3cc260a1f5aa79ae68bd6bc9de6101
5
5
  SHA512:
6
- metadata.gz: 25ce15d5a69099f141387adba4cedb6375842eb9b8c3a798d1e6d1fe1a1c777fcdf4f51d029bb18577300f68b7ff697cb367f15ca5c69f41701ed087f11168ce
7
- data.tar.gz: 31d9e860c78f90e836787a386eff659c56ab2a098cc5fc63d779edf15094e4a3abd14b60f2b906bac1f63b8595110efa2030ef76b980d78c0316cd0d4340ccf8
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
 
@@ -7,7 +7,7 @@ namespace :db do
7
7
  end
8
8
 
9
9
  desc "Load the db/data.sql data into the current database."
10
- task :load => ["db:drop:current", "db:create:current"] do
10
+ task :load => ["db/data.sql", "db:drop:current", "db:create:current"] do
11
11
  Backhoe.load
12
12
  end
13
13
  end
@@ -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
- if local_database?(configuration)
67
- ActiveRecord::Base.establish_connection configuration
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
@@ -1,6 +1,6 @@
1
1
  module Bard
2
2
  module Rake
3
- VERSION = "0.17.0"
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.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: 2019-09-21 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.