Domain_Handler 0.0.18 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/domain_handler.rb +41 -33
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c53879f1c2f12ad82f245076a2528c5abaf26295186664a167db16c043b0c239
|
4
|
+
data.tar.gz: fb2f7078d3a054cf77a35536f66212980cad252856f38c0af0ca86a6f3456fd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c94b6cf43d316e5e05f552c3dc99d70fdf635cedc4332b937491abf177ab6dc09de6cf33ce373d878e7ad58cad64813bf806dbbacd905179c9d81a48f1f6a1
|
7
|
+
data.tar.gz: 93c6b2ec3ce6e0b2743db5f8876acd57f42d157d5c58bbd2bec3f0fbc87d02981cf1b0b7e048460786f1793a98855369699864f0926d17c662858f42cc0202d2
|
data/lib/domain_handler.rb
CHANGED
@@ -68,40 +68,48 @@ class DomainHandler
|
|
68
68
|
)
|
69
69
|
end
|
70
70
|
|
71
|
-
def self.
|
72
|
-
|
73
|
-
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
71
|
+
def self.create_migration
|
72
|
+
migration_name = 'create_domains'
|
73
|
+
|
74
|
+
# Generate a timestamp to use as the migration version
|
75
|
+
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
|
76
|
+
|
77
|
+
# Generate the migration file name
|
78
|
+
migration_file_name = "#{timestamp}_#{migration_name}.rb"
|
79
|
+
|
80
|
+
# Specify the migration class name
|
81
|
+
migration_class_name = migration_name.camelize
|
82
|
+
|
83
|
+
# Specify the migration file path
|
84
|
+
migration_file_path = Rails.root.join('db', 'migrate', migration_file_name)
|
85
|
+
# Create the migration file
|
86
|
+
File.open(migration_file_path, 'w') do |file|
|
87
|
+
file.write("class #{migration_class_name} < ActiveRecord::Migration[6.1]\n")
|
88
|
+
file.write(" def change\n")
|
89
|
+
file.write(" create_table :domains, id: false, primary_key: :domain_id do |t|\n")
|
90
|
+
file.write(" # Define your table columns here\n")
|
91
|
+
file.write(" t.references :shop, foreign_key: true\n")
|
92
|
+
file.write(" t.string :host, null: false, default: ''\n")
|
93
|
+
file.write(" t.string :localization\n")
|
94
|
+
file.write(" t.string :market_web_presence\n")
|
95
|
+
file.write(" t.boolean :ssl_enabled, null: false\n")
|
96
|
+
file.write(" t.string :url\n")
|
97
|
+
file.write(" t.string :domain_id\n")
|
98
|
+
file.write(" t.index :domain_id, unique: true\n")
|
99
|
+
file.write(" t.timestamps\n")
|
100
|
+
file.write(" end\n")
|
101
|
+
file.write(" end\n")
|
102
|
+
file.write("end\n")
|
103
|
+
end
|
87
104
|
|
88
|
-
|
89
|
-
|
105
|
+
model_name = 'domain.rb'
|
106
|
+
model_file_path = Rails.root.join('app', 'models', model_name)
|
107
|
+
File.open(model_file_path, 'w') do |file|
|
108
|
+
file.write("class Domain < ApplicationRecord \n")
|
109
|
+
file.write(" self.primary_key = :domain_id \n")
|
110
|
+
file.write(" belongs_to :shop \n")
|
111
|
+
file.write("end \n")
|
112
|
+
end
|
90
113
|
end
|
91
114
|
end
|
92
115
|
|
93
|
-
class CreateDomains < ActiveRecord::Migration[5.0]
|
94
|
-
def change
|
95
|
-
create_table :domains, id: false, primary_key: :domain_id do |t|
|
96
|
-
t.references :shop, foreign_key: true
|
97
|
-
t.string :host, null: false, default: ''
|
98
|
-
t.string :localization
|
99
|
-
t.string :market_web_presence
|
100
|
-
t.boolean :ssl_enabled, null: false
|
101
|
-
t.string :url
|
102
|
-
t.string :domain_id
|
103
|
-
t.index :domain_id, unique: true
|
104
|
-
t.timestamps
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|