modular_migration 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/README.md +5 -5
- data/lib/modular_migration/active_record/generators/migration_generator.rb +7 -7
- data/lib/modular_migration/active_record/generators/model_generator.rb +6 -1
- data/lib/modular_migration/version.rb +1 -1
- data/modular_migration.gemspec +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e3971848b0754cd92436f98ea498148aa13bc43e679cb69a25cbe8f17be75169
|
4
|
+
data.tar.gz: 0f99e22f217f7fa019cc8cec7e2ef4e4a399160572625d2cbcc62cc89d524df1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b94ccf2748f53419118299d00538f6e32e57c445c54d28dd126fb8a8b174810ce30d81fde0f43d5a7e321f20af826beb4961446b0838f4c87100df8f7ace7aca
|
7
|
+
data.tar.gz: db78c3f5b194ef7aae8ddb21c631ec303c14e85147b6b5c8a8f59d6428afd7a6d4312540302f102aaace6b450a0d42e30cd141b85100c7000a97bda7bbb22afd
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Do nothing.
|
|
25
25
|
## Example
|
26
26
|
|
27
27
|
- Generate model
|
28
|
-
|
28
|
+
|
29
29
|
```bash
|
30
30
|
$ rails g model core/user name:string
|
31
31
|
invoke active_record
|
@@ -35,17 +35,17 @@ Do nothing.
|
|
35
35
|
```
|
36
36
|
|
37
37
|
- Generate migration
|
38
|
-
|
38
|
+
|
39
39
|
```bash
|
40
40
|
$ rails g migration AddGenderToCoreUser gender:integer
|
41
41
|
invoke active_record
|
42
42
|
create db/migrate/core/user/20140324105719_add_gender_to_core_user.rb
|
43
43
|
```
|
44
44
|
|
45
|
-
##
|
45
|
+
## Sponsors
|
46
|
+
|
47
|
+
* [BaiLu ShuYuan](https://bailushuyuan.org)
|
46
48
|
|
47
|
-
- [LiJia.Tong](https://github.com/user-tony/) @[Ihaveu](https://www.ihaveu.com/home)
|
48
|
-
|
49
49
|
## License
|
50
50
|
|
51
51
|
Copyright © 2014 Lijia Tong <user_tony@163.com> under The [MIT License](http://opensource.org/licenses/MIT).
|
@@ -4,8 +4,8 @@ module ActiveRecord
|
|
4
4
|
|
5
5
|
def create_migration_file
|
6
6
|
set_local_assigns!
|
7
|
-
validate_file_name!
|
8
|
-
if migration_action.match(/(add|remove)/)
|
7
|
+
validate_file_name! if self.respond_to?(:validate_file_name)
|
8
|
+
if migration_action && migration_action.match(/(add|remove)/)
|
9
9
|
table = table_name.singularize
|
10
10
|
modular = table.gsub(/_/, '/').camelize.safe_constantize
|
11
11
|
table = table.split('_')
|
@@ -20,13 +20,13 @@ module ActiveRecord
|
|
20
20
|
end unless modular
|
21
21
|
migration = modular ? modular.to_s.underscore : []
|
22
22
|
end
|
23
|
-
migration = join_tables.map(&:singularize).join('_') if migration_action.match(/join/)
|
24
|
-
|
25
|
-
migration_file = File.join(migration
|
26
|
-
|
23
|
+
migration = join_tables.map(&:singularize).join('_') if migration_action && migration_action.match(/join/)
|
24
|
+
FileUtils.mkdir_p(File.join("db", "migrate", migration)) if migration
|
25
|
+
migration_file = File.join("db", "migrate", migration||"", "#{file_name}.rb")
|
26
|
+
template_file = Rails.version.to_i < 4 ? 'migration.rb' : @migration_template
|
27
|
+
migration_template template_file, migration_file
|
27
28
|
end
|
28
29
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
32
|
-
|
@@ -2,7 +2,12 @@ module ActiveRecord
|
|
2
2
|
module Generators # :nodoc:
|
3
3
|
class ModelGenerator < Base # :nodoc:
|
4
4
|
|
5
|
-
|
5
|
+
class_option :migration, type: :boolean, default: true
|
6
|
+
class_option :timestamps, type: :boolean, default: true
|
7
|
+
|
8
|
+
def create_migration_file
|
9
|
+
return unless options[:migration] && options[:parent].nil?
|
10
|
+
attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false
|
6
11
|
template_file = Rails.version.to_i < 4 ? 'migration.rb' : '../../migration/templates/create_table_migration.rb'
|
7
12
|
migration_file = File.join(FileUtils.mkdir_p(File.join('db/migrate', class_path.join('/'), file_name)), "/create_#{table_name}.rb")
|
8
13
|
migration_template template_file, migration_file
|
data/modular_migration.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.author = ['Lijia Tong']
|
9
9
|
s.email = ["user_tony@163.com"]
|
10
|
-
s.homepage = "https://
|
10
|
+
s.homepage = "https://bailushuyuan.org"
|
11
11
|
s.summary = "Rails migration files generates into relevant modular directory"
|
12
12
|
s.description = "Rails migration files generates into relevant modular directory."
|
13
13
|
s.license = "MIT"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modular_migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lijia Tong
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -42,11 +42,11 @@ files:
|
|
42
42
|
- lib/modular_migration/active_record/generators/model_generator.rb
|
43
43
|
- lib/modular_migration/version.rb
|
44
44
|
- modular_migration.gemspec
|
45
|
-
homepage: https://
|
45
|
+
homepage: https://bailushuyuan.org
|
46
46
|
licenses:
|
47
47
|
- MIT
|
48
48
|
metadata: {}
|
49
|
-
post_install_message:
|
49
|
+
post_install_message:
|
50
50
|
rdoc_options: []
|
51
51
|
require_paths:
|
52
52
|
- lib
|
@@ -61,9 +61,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
|
-
|
65
|
-
|
66
|
-
signing_key:
|
64
|
+
rubygems_version: 3.3.3
|
65
|
+
signing_key:
|
67
66
|
specification_version: 4
|
68
67
|
summary: Rails migration files generates into relevant modular directory
|
69
68
|
test_files: []
|