activerecord-migrations 1.1.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bake/activerecord/deploy.rb +6 -0
- data/bake/activerecord/environment.rb +9 -0
- data/lib/active_record/migrations/generator.rb +41 -0
- data/lib/active_record/migrations/tasks.rb +6 -4
- data/lib/active_record/migrations/tasks/db.rb +37 -21
- data/lib/active_record/migrations/tasks/db/fixtures.rb +61 -14
- data/lib/active_record/migrations/tasks/db/migrations.rb +3 -2
- data/lib/active_record/migrations/tasks/db/seed.rb +28 -0
- data/lib/active_record/migrations/version.rb +1 -1
- metadata +88 -31
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.simplecov +0 -9
- data/.travis.yml +0 -6
- data/Gemfile +0 -14
- data/README.md +0 -104
- data/Rakefile +0 -12
- data/activerecord-migrations.gemspec +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0a63e0a40b3bb11fb0472d0a71507223943732350ed7ff7d9f093c45a69b30d9
|
4
|
+
data.tar.gz: 5b28d403e9d8e2b6d798fa5730f6213d977bfea59708eccf8c0f3b7b33e8d565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79eb1392d02d5ae1bbf82cbd4a33145ce98ebe0f64f3e5f71ca1a00bfe43f2a62e9a5e3c28d10b615ef40a99996a820f00f9cccaa56a808791605783b160716a
|
7
|
+
data.tar.gz: 4bdfb2ece3ef87131dacfc03534f8c261bfd6f4c5290edd2271904edf9a5f92340b355ea0e4dc01adb9fc066056051bf2d1c57f71872e58747d64400970a64c5
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'rails/generators'
|
22
|
+
require 'rails/generators/active_record/migration/migration_generator'
|
23
|
+
require 'active_record/tasks/database_tasks'
|
24
|
+
|
25
|
+
module ActiveRecord
|
26
|
+
module Migrations
|
27
|
+
class Generator < ::ActiveRecord::Generators::MigrationGenerator
|
28
|
+
source_root ::ActiveRecord::Generators::MigrationGenerator.source_root
|
29
|
+
|
30
|
+
def create_migration_file
|
31
|
+
set_local_assigns!
|
32
|
+
validate_file_name!
|
33
|
+
migration_template @migration_template, File.join(db_migrate_path, "#{file_name}.rb")
|
34
|
+
end
|
35
|
+
|
36
|
+
def db_migrate_path
|
37
|
+
::ActiveRecord::Migrations.migrations_root
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -19,13 +19,15 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require_relative 'tasks/db'
|
22
|
-
require_relative 'tasks/db/migrations'
|
23
|
-
require_relative 'tasks/db/fixtures'
|
24
22
|
|
25
23
|
module ActiveRecord
|
26
24
|
module Migrations
|
27
25
|
class << self
|
28
26
|
attr_accessor :root
|
27
|
+
|
28
|
+
def migrations_root
|
29
|
+
File.join(self.root, 'db/migrate')
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.database?
|
@@ -38,9 +40,9 @@ module ActiveRecord
|
|
38
40
|
if defined? Tasks::DatabaseTasks
|
39
41
|
module Tasks
|
40
42
|
module DatabaseTasks
|
41
|
-
def each_current_configuration(environment)
|
43
|
+
def each_current_configuration(environment, spec_name = nil)
|
42
44
|
unless configuration = ActiveRecord::Base.configurations[environment]
|
43
|
-
raise ArgumentError.new("Cannot find configuration for environment #{environment}")
|
45
|
+
raise ArgumentError.new("Cannot find configuration for environment #{environment.inspect} in #{ActiveRecord::Base.configurations.keys}")
|
44
46
|
end
|
45
47
|
|
46
48
|
# This is a hack because DatabaseTasks functionality uses string for keys.
|
@@ -18,6 +18,13 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require 'rake'
|
22
|
+
require 'variant'
|
23
|
+
|
24
|
+
task :environment do
|
25
|
+
# Can be overriden by user.
|
26
|
+
end
|
27
|
+
|
21
28
|
namespace :db do
|
22
29
|
task :load_config => :environment do
|
23
30
|
database_tasks = ActiveRecord::Tasks::DatabaseTasks
|
@@ -26,9 +33,8 @@ namespace :db do
|
|
26
33
|
abort "ActiveRecord::Migrations.root needs to be set!"
|
27
34
|
end
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
36
|
+
# DATABASE_ENV is a legacy environment variable:
|
37
|
+
variant = Variant.for(:database) || DATABASE_ENV
|
32
38
|
|
33
39
|
if ActiveRecord::Base.configurations.empty?
|
34
40
|
abort "ActiveRecord::Base.configurations needs to be setup!"
|
@@ -36,27 +42,42 @@ namespace :db do
|
|
36
42
|
|
37
43
|
database_tasks.root = root
|
38
44
|
database_tasks.db_dir = File.join(root, 'db')
|
39
|
-
database_tasks.env =
|
45
|
+
database_tasks.env = variant.to_s
|
40
46
|
database_tasks.database_configuration = ActiveRecord::Base.configurations
|
41
|
-
database_tasks.migrations_paths = File.join(root, 'db/migrate')
|
42
|
-
database_tasks.fixtures_path = File.join(root, 'db/fixtures',
|
47
|
+
database_tasks.migrations_paths = [File.join(root, 'db/migrate')]
|
48
|
+
database_tasks.fixtures_path = File.join(root, 'db/fixtures', variant.to_s)
|
43
49
|
|
44
50
|
database_tasks.send(:define_method, :load_seed) do
|
45
51
|
load File.join(root, 'db/seed.rb')
|
46
52
|
end
|
47
53
|
end
|
48
54
|
|
49
|
-
task
|
50
|
-
task :deploy => :load_config do
|
55
|
+
task :schema_path => :load_config do
|
51
56
|
database_tasks = ActiveRecord::Tasks::DatabaseTasks
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
paths = [
|
59
|
+
ENV['SCHEMA'],
|
60
|
+
File.join(database_tasks.fixtures_path, 'schema.rb'),
|
61
|
+
File.join(database_tasks.db_dir, 'schema.rb'),
|
62
|
+
].compact
|
63
|
+
|
64
|
+
unless @schema_path = paths.select{|path| File.exist?(path)}.first
|
65
|
+
abort "Could not locate schema file: #{paths.inspect}!"
|
56
66
|
end
|
57
67
|
|
68
|
+
puts "Found schema: #{@schema_path}"
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Setup a new database if required and run migrations.'
|
72
|
+
task :deploy => [:load_config, :schema_path] do
|
73
|
+
database_tasks = ActiveRecord::Tasks::DatabaseTasks
|
74
|
+
|
58
75
|
unless ActiveRecord::Migrations.database?
|
59
|
-
Rake::Task['db:
|
76
|
+
Rake::Task['db:create'].invoke
|
77
|
+
|
78
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, @schema_path)
|
79
|
+
|
80
|
+
Rake::Task['db:seed'].invoke
|
60
81
|
end
|
61
82
|
|
62
83
|
Rake::Task['db:migrate'].invoke
|
@@ -88,12 +109,7 @@ end
|
|
88
109
|
# Loading this AFTER we define our own load_config task is critical, we need to make sure things are set up correctly before we run the task of the same name from ActiveRecord.
|
89
110
|
load 'active_record/railties/databases.rake'
|
90
111
|
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
desc 'Load the seed data into the database.'
|
96
|
-
task :seed do
|
97
|
-
ActiveRecord::Tasks::DatabaseTasks.load_seed
|
98
|
-
end
|
99
|
-
end
|
112
|
+
# We load these afterwards as it augments/replace the existing tasks:
|
113
|
+
require_relative 'db/seed'
|
114
|
+
require_relative 'db/fixtures'
|
115
|
+
require_relative 'db/migrations'
|
@@ -1,42 +1,89 @@
|
|
1
|
+
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
1
20
|
|
2
21
|
namespace :db do
|
3
22
|
namespace :fixtures do
|
4
|
-
task :
|
23
|
+
task :fixtures_path => :load_config do
|
24
|
+
@fixtures_path = ENV.fetch('FIXTURES_PATH') {ActiveRecord::Tasks::DatabaseTasks.fixtures_path}
|
25
|
+
@tables_path = File.join(@fixtures_path, 'tables.conf')
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'List the tables to be dumped, either via `ENV[\'TABLES\']` or `tables.conf`.'
|
29
|
+
task :tables => :fixtures_path do
|
5
30
|
all_tables = ActiveRecord::Base.connection.tables
|
6
31
|
|
7
32
|
if tables_string = ENV['TABLES']
|
8
33
|
@tables = tables_string.split(',')
|
34
|
+
elsif File.exist?(@tables_path)
|
35
|
+
puts "Loading tables from: #{@tables_path}"
|
36
|
+
@tables = YAML::load_file(@tables_path)
|
9
37
|
else
|
10
38
|
# We skip update/event tables since these contain a lot of non-critical data.
|
11
|
-
@tables = all_tables.grep_v(
|
39
|
+
@tables = all_tables.grep_v(/ar_internal_metadata/)
|
12
40
|
end
|
13
41
|
|
14
|
-
puts "Dumping
|
15
|
-
puts "Skipping
|
42
|
+
puts "Dumping tables: #{@tables.join(', ')}"
|
43
|
+
puts "Skipping tables: #{(all_tables - @tables).join(', ')}"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'Copy the current schema to the fixtures schema.'
|
47
|
+
task :copy_schema => :fixtures_path do
|
48
|
+
database_tasks = ActiveRecord::Tasks::DatabaseTasks
|
49
|
+
|
50
|
+
fixtures_schema_path = File.join(database_tasks.fixtures_path, 'schema.rb')
|
51
|
+
db_schema_path = File.join(database_tasks.db_dir, 'schema.rb')
|
52
|
+
|
53
|
+
FileUtils.cp(db_schema_path, fixtures_schema_path)
|
16
54
|
end
|
17
55
|
|
18
56
|
desc 'Create YAML fixtures from data in an existing database.'
|
19
57
|
task :dump => :tables do
|
20
|
-
sql
|
58
|
+
sql = "SELECT * FROM %s"
|
21
59
|
|
22
|
-
|
23
|
-
FileUtils.mkpath root
|
60
|
+
FileUtils.mkpath @fixtures_path
|
24
61
|
|
25
62
|
@tables.each do |table_name|
|
26
|
-
|
63
|
+
# It's with regret that we have to use .yml here, as that's the only extension supported by ActiveRecord db:fixtures:load
|
64
|
+
fixture_path = "#{@fixtures_path}/#{table_name}.yml"
|
27
65
|
|
28
66
|
puts "Dumping #{table_name} to #{fixture_path}..."
|
29
67
|
|
30
68
|
i = "000"
|
31
69
|
|
32
70
|
File.open(fixture_path, 'w') do |file|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
hash
|
37
|
-
|
71
|
+
rows = ActiveRecord::Base.connection.select_all(sql % table_name)
|
72
|
+
|
73
|
+
records = rows.each_with_object({}) do |row, hash|
|
74
|
+
hash["#{table_name}_#{i.succ!}"] = row
|
75
|
+
end
|
76
|
+
|
77
|
+
file.write records.to_yaml
|
38
78
|
end
|
39
79
|
end
|
40
80
|
end
|
81
|
+
|
82
|
+
desc 'Update the fixtures and copy the schema.'
|
83
|
+
task :update => [:copy_schema, :dump] do
|
84
|
+
unless File.exist? @tables_path
|
85
|
+
File.write(@tables_path, YAML::dump(@tables))
|
86
|
+
end
|
87
|
+
end
|
41
88
|
end
|
42
|
-
end
|
89
|
+
end
|
@@ -32,10 +32,11 @@ namespace :db do
|
|
32
32
|
options = []
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
require_relative '../../generator'
|
36
36
|
|
37
37
|
parameters = [name] + options
|
38
|
-
|
38
|
+
|
39
|
+
Rails::Generators.invoke "active_record:migrations:generator", parameters, :destination_root => ActiveRecord::Migrations.root
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
# Now we work around some existing broken tasks:
|
22
|
+
Rake::Task['db:seed'].clear
|
23
|
+
|
24
|
+
namespace :db do
|
25
|
+
desc 'Load the seed data into the database.'
|
26
|
+
task :seed => 'db:fixtures:load' do
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '7'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5
|
29
|
+
version: '5'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: railties
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
39
|
+
version: '0'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rainbow
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +58,76 @@ dependencies:
|
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '2.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: variant
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: bake-bundler
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: bake-modernize
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
55
103
|
- !ruby/object:Gem::Dependency
|
56
104
|
name: bundler
|
57
105
|
requirement: !ruby/object:Gem::Requirement
|
58
106
|
requirements:
|
59
|
-
- - "
|
107
|
+
- - ">="
|
60
108
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
109
|
+
version: '0'
|
62
110
|
type: :development
|
63
111
|
prerelease: false
|
64
112
|
version_requirements: !ruby/object:Gem::Requirement
|
65
113
|
requirements:
|
66
|
-
- - "
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: covered
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
67
129
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
130
|
+
version: '0'
|
69
131
|
- !ruby/object:Gem::Dependency
|
70
132
|
name: rake
|
71
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,32 +156,28 @@ dependencies:
|
|
94
156
|
- - "~>"
|
95
157
|
- !ruby/object:Gem::Version
|
96
158
|
version: '3.0'
|
97
|
-
description:
|
159
|
+
description:
|
98
160
|
email:
|
99
|
-
- samuel.williams@oriontransfer.co.nz
|
100
161
|
executables: []
|
101
162
|
extensions: []
|
102
163
|
extra_rdoc_files: []
|
103
164
|
files:
|
104
|
-
-
|
105
|
-
-
|
106
|
-
- ".simplecov"
|
107
|
-
- ".travis.yml"
|
108
|
-
- Gemfile
|
109
|
-
- README.md
|
110
|
-
- Rakefile
|
111
|
-
- activerecord-migrations.gemspec
|
165
|
+
- bake/activerecord/deploy.rb
|
166
|
+
- bake/activerecord/environment.rb
|
112
167
|
- lib/active_record/migrations.rb
|
168
|
+
- lib/active_record/migrations/generator.rb
|
113
169
|
- lib/active_record/migrations/tasks.rb
|
114
170
|
- lib/active_record/migrations/tasks/db.rb
|
115
171
|
- lib/active_record/migrations/tasks/db/fixtures.rb
|
116
172
|
- lib/active_record/migrations/tasks/db/migrations.rb
|
173
|
+
- lib/active_record/migrations/tasks/db/seed.rb
|
117
174
|
- lib/active_record/migrations/version.rb
|
118
175
|
homepage: https://github.com/ioquatix/activerecord-migrations
|
119
176
|
licenses:
|
120
177
|
- MIT
|
121
|
-
metadata:
|
122
|
-
|
178
|
+
metadata:
|
179
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
180
|
+
post_install_message:
|
123
181
|
rdoc_options: []
|
124
182
|
require_paths:
|
125
183
|
- lib
|
@@ -134,9 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
192
|
- !ruby/object:Gem::Version
|
135
193
|
version: '0'
|
136
194
|
requirements: []
|
137
|
-
|
138
|
-
|
139
|
-
signing_key:
|
195
|
+
rubygems_version: 3.1.2
|
196
|
+
signing_key:
|
140
197
|
specification_version: 4
|
141
198
|
summary: Provides a opinionated migration wrapper for ActiveRecord 5+
|
142
199
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.simplecov
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in activerecord-migrations.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem "sqlite3"
|
8
|
-
gem "mysql2"
|
9
|
-
end
|
10
|
-
|
11
|
-
group :test do
|
12
|
-
gem 'simplecov'
|
13
|
-
gem 'coveralls', require: false
|
14
|
-
end
|
data/README.md
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
# ActiveRecord::Migrations
|
2
|
-
|
3
|
-
This gem provides opinionated support for ActiveRecord migrations in non-Rails applications. It's more opinionated than [active_record_migrations](https://github.com/rosenfeld/active_record_migrations) and [standalone-migrations](https://github.com/thuss/standalone-migrations), and therefore simpler to configure.
|
4
|
-
|
5
|
-
[![Build Status](https://secure.travis-ci.org/ioquatix/activerecord-migrations.svg)](http://travis-ci.org/ioquatix/activerecord-migrations)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/ioquatix/activerecord-migrations.svg)](https://codeclimate.com/github/ioquatix/activerecord-migrations)
|
7
|
-
[![Coverage Status](https://coveralls.io/repos/ioquatix/activerecord-migrations/badge.svg)](https://coveralls.io/r/ioquatix/activerecord-migrations)
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
Add this line to your application's Gemfile:
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
gem 'activerecord-migrations'
|
15
|
-
```
|
16
|
-
|
17
|
-
## Usage
|
18
|
-
|
19
|
-
Add something like this to `tasks/db.rake`
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
require 'active_record/migrations/tasks'
|
23
|
-
# The root must be the root of your application, and contain `db/`.
|
24
|
-
ActiveRecord::Migrations.root = File.dirname(__dir__)
|
25
|
-
```
|
26
|
-
|
27
|
-
Somewhere else, ensure you have a suitable `environment` task, e.g:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
task :environment do
|
31
|
-
# This must be a symbol... or establish_connection thinks it's a URL.
|
32
|
-
DATABASE_ENV = :development
|
33
|
-
|
34
|
-
ActiveRecord::Base.configurations = {
|
35
|
-
# This key must be a string or it will not be matched by ActiveRecord:
|
36
|
-
'development' => {
|
37
|
-
# Using symbols for keys is fixed by this gem.
|
38
|
-
adapter: => 'sqlite3',
|
39
|
-
database: => 'db/development.db'
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
# Connect to database:
|
44
|
-
unless ActiveRecord::Base.connected?
|
45
|
-
ActiveRecord::Base.establish_connection(DATABASE_ENV)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
```
|
49
|
-
|
50
|
-
### Deployment
|
51
|
-
|
52
|
-
This gem includes an additional task `db:deploy` which is designed to assist with deployment of sites with databases. When deploying a site for the first time, this task will create the database and load the seed data. If deploying the site to an existing database it will simply run migrations.
|
53
|
-
|
54
|
-
### `db/seed.rb`
|
55
|
-
|
56
|
-
This file should contain the logic for loading your fixtures or other seed data. Something like this:
|
57
|
-
|
58
|
-
```ruby
|
59
|
-
require_relative 'environment'
|
60
|
-
|
61
|
-
puts "Loading fixtures..."
|
62
|
-
system("rake", "db:fixtures:load")
|
63
|
-
```
|
64
|
-
|
65
|
-
### Fixtures
|
66
|
-
|
67
|
-
Fixtures are generated into `db/fixtures/#{environment}/table.yml` by running `rake db:fixtures:dump`.
|
68
|
-
|
69
|
-
## Contributing
|
70
|
-
|
71
|
-
1. Fork it
|
72
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
75
|
-
5. Create new Pull Request
|
76
|
-
|
77
|
-
## See Also
|
78
|
-
|
79
|
-
- [ActiveRecord::Rack](https://github.com/ioquatix/activerecord-rack)
|
80
|
-
|
81
|
-
## License
|
82
|
-
|
83
|
-
Released under the MIT license.
|
84
|
-
|
85
|
-
Copyright, 2016, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
86
|
-
|
87
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
88
|
-
of this software and associated documentation files (the "Software"), to deal
|
89
|
-
in the Software without restriction, including without limitation the rights
|
90
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
91
|
-
copies of the Software, and to permit persons to whom the Software is
|
92
|
-
furnished to do so, subject to the following conditions:
|
93
|
-
|
94
|
-
The above copyright notice and this permission notice shall be included in
|
95
|
-
all copies or substantial portions of the Software.
|
96
|
-
|
97
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
98
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
99
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
100
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
101
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
102
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
103
|
-
THE SOFTWARE.
|
104
|
-
|
data/Rakefile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
5
|
-
begin
|
6
|
-
require('simplecov/version')
|
7
|
-
task.rspec_opts = %w{--require simplecov} if ENV['COVERAGE']
|
8
|
-
rescue LoadError
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
task :default => :spec
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require_relative 'lib/active_record/migrations/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "activerecord-migrations"
|
6
|
-
spec.version = ActiveRecord::Migrations::VERSION
|
7
|
-
spec.authors = ["Samuel Williams"]
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
-
|
10
|
-
spec.summary = %q{Provides a opinionated migration wrapper for ActiveRecord 5+}
|
11
|
-
spec.homepage = "https://github.com/ioquatix/activerecord-migrations"
|
12
|
-
spec.license = "MIT"
|
13
|
-
|
14
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
-
f.match(%r{^(test|spec|features)/})
|
16
|
-
end
|
17
|
-
spec.bindir = "exe"
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency "activerecord", "~> 5.0"
|
22
|
-
spec.add_dependency "railties", "~> 5.0"
|
23
|
-
|
24
|
-
spec.add_dependency "rainbow", "~> 2.0"
|
25
|
-
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.13"
|
27
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
-
end
|