versionize_old_migrations 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/versionize_old_migrations.rb +33 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b08741b3bd5294180711b51d4bde9cac9cdc1b39c51b067f7c3c2799dc74ad52
|
4
|
+
data.tar.gz: 1cc1393c8daa524310b25c6701999a33ca8d1f602673df63d53e0503370e063b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98646c2ab66664c957fe8116a338fe8a262943b069706be4bdbd12d71b18facba905357a97b63a3112a54c6e4e95c80931bcffd3698b07550702baa0133400c2
|
7
|
+
data.tar.gz: a47a7dc5437a3b5f1595b18cb7b9c8f9bd646e88ba2b6fb2773bf12a160975df36103541f33946dd555b8e0359e070af5fe7d9ff7ba4670557ec7772c18280c2
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# For each migration file in the current directory, appends '[4.2]' to the migration base class.
|
2
|
+
#
|
3
|
+
# Example:
|
4
|
+
# First line of migration before:
|
5
|
+
# class CreateFooTable < ActiveRecord::Migration
|
6
|
+
# First line of migration after:
|
7
|
+
# class CreateFooTable < ActiveRecord::Migration[4.2]
|
8
|
+
#
|
9
|
+
# Context:
|
10
|
+
# Rails 5 requires that all migration files have the version of Rails they were created in, appended to the migration base class.
|
11
|
+
# Migrations created prior to Rails 5 should have version [4.2] appended.
|
12
|
+
#
|
13
|
+
# Assumptions:
|
14
|
+
# Run from the directory containing the migration files.
|
15
|
+
# The migration files are not already versioned.
|
16
|
+
# The migration files have the class declaration, including "ActiveRecord::Migration", on the first line of the file
|
17
|
+
|
18
|
+
class VersionizeOldMigrations
|
19
|
+
def self.versionize
|
20
|
+
Dir.glob("*.rb") do |rb_file|
|
21
|
+
puts "working on #{rb_file} ..."
|
22
|
+
input = File.open(rb_file, 'r')
|
23
|
+
lines = input.readlines
|
24
|
+
puts lines[0]
|
25
|
+
lines[0].gsub!("ActiveRecord::Migration", "ActiveRecord::Migration[4.2]")
|
26
|
+
puts lines[0]
|
27
|
+
output = File.open(rb_file, 'w')
|
28
|
+
lines.each do |line|
|
29
|
+
output.write(line)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: versionize_old_migrations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Buck Melton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Beginning with Rails 5, migrations must have the Rails version they were
|
14
|
+
created with appended to the base class name ActiveRecord::Migration. Migrations
|
15
|
+
created prior to Rails 5 should have [4.2] appended, which is what this gem does.
|
16
|
+
email: buck9063@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/versionize_old_migrations.rb
|
22
|
+
homepage: https://rubygems.org/gems/versionize_old_migrations
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.7.8
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Add [4.2] version to unversioned migrations
|
46
|
+
test_files: []
|