Domain_Handler 0.0.18 → 0.0.19
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 +42 -34
- 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: b5388e6098b20e3a270abbc2ddb57ae34a6019181dbc745b07f10c05a33b10ac
|
4
|
+
data.tar.gz: 3d22f4700b849b794924aef5b0f79b233bba14c64b573aefce6b0911981ebc78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd847d76fe25afec4304c8b9fc7a0f63b595bd33f76b328381d8b09936d284d2a4becedccdf3d2bf3f884aade2b0f4a22f8b2ac39e871c52246a2555741247e
|
7
|
+
data.tar.gz: 640c1e604aead80ec89f06a8536ee71d62b8d30f9db5c3b85655387a5845981ccc8752c0ce31f4a00031571f03ab1e75c309123acac5900b12649dec01e78759
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
92
104
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
t.string :url
|
102
|
-
t.string :domain_id
|
103
|
-
t.index :domain_id, unique: true
|
104
|
-
t.timestamps
|
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(" belongs_to :shop \n")
|
112
|
+
file.write("end \n")
|
105
113
|
end
|
106
114
|
end
|
107
|
-
end
|
115
|
+
end
|