old_sql 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module OldSql
|
5
|
+
class InstallDeviseMigrationsGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
source_root File.expand_path('../templates/devise', __FILE__)
|
8
|
+
|
9
|
+
def self.next_migration_number(dirname)
|
10
|
+
if ActiveRecord::Base.timestamped_migrations
|
11
|
+
migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
12
|
+
migration_number += 1
|
13
|
+
migration_number.to_s
|
14
|
+
else
|
15
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_migration_file
|
20
|
+
migration_template 'add_devise_to_users_migration.rb', 'db/migrate/add_devise_to_users.rb' rescue p $!.message
|
21
|
+
#sleep 1 # ensure scripts have different timestamps
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -6,9 +6,10 @@ module OldSql
|
|
6
6
|
desc "Old SQL Install"
|
7
7
|
|
8
8
|
def check_for_devise
|
9
|
-
puts "Hello!
|
9
|
+
puts "Hello!
|
10
10
|
Old SQL works with devise. Checking for a current installation of devise!
|
11
11
|
"
|
12
|
+
|
12
13
|
if defined?(Devise)
|
13
14
|
check_for_devise_models
|
14
15
|
else
|
@@ -33,11 +34,34 @@ Old SQL works with devise. Checking for a current installation of devise!
|
|
33
34
|
parse_route_files
|
34
35
|
else
|
35
36
|
puts "Looks like you don't have devise install! We'll install it for you!"
|
36
|
-
|
37
|
+
|
38
|
+
if !user_model_exists?
|
39
|
+
invoke 'devise:install'
|
40
|
+
elsif !user_model_has_devise?
|
41
|
+
invoke 'old_sql:install_devise_migrations'
|
42
|
+
end
|
43
|
+
|
37
44
|
set_devise
|
38
45
|
|
39
46
|
end
|
40
47
|
end
|
48
|
+
|
49
|
+
def user_model_exists
|
50
|
+
app_path = Rails.public_path.split("/")
|
51
|
+
app_path.delete_at(-1)
|
52
|
+
app_path = app_path.join("/")
|
53
|
+
|
54
|
+
File.exists?(app_path+'/app/models/user.rb')
|
55
|
+
end
|
56
|
+
|
57
|
+
def user_model_has_devise?
|
58
|
+
has_devise? = false
|
59
|
+
gsub_file app_path+'/app/models/user.rb', /devise/, :green do |match|
|
60
|
+
puts "User model already has devise"
|
61
|
+
has_devise? = true
|
62
|
+
end
|
63
|
+
has_devise?
|
64
|
+
end
|
41
65
|
|
42
66
|
def parse_route_files
|
43
67
|
# check if migrations exist
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class AddDeviseToUsers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :users, :database_authenticatable, :null => false
|
4
|
+
add_column :users, :recoverable
|
5
|
+
add_column :users, :rememberable
|
6
|
+
add_column :users, :trackable
|
7
|
+
#add_column :users, :encryptable
|
8
|
+
#add_column :users, :confirmable
|
9
|
+
#add_column :users, :lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
|
10
|
+
add_column :users, :token_authenticatable
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
remove_column :users, :database_authenticatable, :null => false
|
15
|
+
remove_column :users, :recoverable
|
16
|
+
remove_column :users, :rememberable
|
17
|
+
remove_column :users, :trackable
|
18
|
+
#remove_column :users, :encryptable
|
19
|
+
#remove_column :users, :confirmable
|
20
|
+
#remove_column :users, :lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
|
21
|
+
remove_column :users, :token_authenticatable
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: old_sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.11.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eddie Gonzales
|
@@ -81,10 +81,12 @@ files:
|
|
81
81
|
- config/routes.rb
|
82
82
|
- lib/extensions/action_controller/base.rb
|
83
83
|
- lib/generators/old_sql/USAGE
|
84
|
+
- lib/generators/old_sql/install_devise_migrations_generator.rb
|
84
85
|
- lib/generators/old_sql/install_generator.rb
|
85
86
|
- lib/generators/old_sql/install_migrations_generator.rb
|
86
87
|
- lib/generators/old_sql/old_sql_generator.rb
|
87
88
|
- lib/generators/old_sql/templates/add_old_sql_admin_to_users_migration.rb
|
89
|
+
- lib/generators/old_sql/templates/devise/add_devise_to_users.rb
|
88
90
|
- lib/old_sql.rb
|
89
91
|
- lib/old_sql/engine.rb
|
90
92
|
- lib/old_sql/report_processor/base.rb
|
@@ -189,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
191
|
requirements:
|
190
192
|
- - ">="
|
191
193
|
- !ruby/object:Gem::Version
|
192
|
-
hash:
|
194
|
+
hash: 3313876361865772528
|
193
195
|
segments:
|
194
196
|
- 0
|
195
197
|
version: "0"
|