migration-manager 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.
@@ -0,0 +1,180 @@
1
+ <div class="form-container">
2
+ <h2>Create a New Migration</h2>
3
+
4
+ <%= form_with url: migration_manager.create_migration_path, method: :post do |f| %>
5
+
6
+ <div class="form-group">
7
+ <label class="form-label">Operation Type</label>
8
+ <%= f.select :operation, ['Create Table', 'Add Column', 'Remove Column'], {}, id: "operation_type", class: "form-select" %>
9
+ </div>
10
+
11
+ <!-- Table Name Field (Shown for Create Table) -->
12
+ <div class="form-group" id="table_name_field">
13
+ <label class="form-label">Table Name</label>
14
+ <%= f.text_field :table_name, class: "form-input" %>
15
+ </div>
16
+
17
+ <!-- Table Selection Dropdown (Shown for Add Column) -->
18
+ <div class="form-group" id="table_select_field" style="display: none;">
19
+ <label class="form-label">Select Table</label>
20
+ <%= f.select :table_name, @tables, {}, class: "form-select" %>
21
+ </div>
22
+
23
+ <div id="columns_section">
24
+ <div class="form-group column-group">
25
+ <label class="form-label">Column Name</label>
26
+ <input type="text" name="columns[][name]" class="form-input" placeholder="Enter column name">
27
+
28
+ <label class="form-label">Column Type</label>
29
+ <select name="columns[][type]" class="form-select">
30
+ <option value="string">String</option>
31
+ <option value="integer">Integer</option>
32
+ <option value="boolean">Boolean</option>
33
+ <option value="text">Text</option>
34
+ <option value="date">Date</option>
35
+ <option value="datetime">Datetime</option>
36
+ <option value="jsonb">JSONB</option>
37
+ </select>
38
+
39
+ <label class="form-label">Default Value</label>
40
+ <input type="text" name="columns[][default]" class="form-input" placeholder="Optional default value">
41
+
42
+ <button type="button" class="remove-column form-button">Remove</button>
43
+ </div>
44
+ </div>
45
+
46
+ <button type="button" id="add_column" class="form-button">Add Column</button>
47
+
48
+ <%= f.submit "Create Migration", class: "form-button" %>
49
+ <% end %>
50
+ </div>
51
+ <style>
52
+ /* Custom styles for Migration Manager */
53
+ .form-container {
54
+ max-width: 600px;
55
+ margin: 20px auto;
56
+ padding: 20px;
57
+ background: #f8f9fa;
58
+ border-radius: 8px;
59
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
60
+ }
61
+
62
+ .form-group {
63
+ margin-bottom: 15px;
64
+ }
65
+
66
+ .form-label {
67
+ font-weight: bold;
68
+ display: block;
69
+ margin-bottom: 5px;
70
+ }
71
+
72
+ .form-input, .form-select {
73
+ width: 100%;
74
+ padding: 8px;
75
+ border: 1px solid #ced4da;
76
+ border-radius: 5px;
77
+ }
78
+
79
+ .hidden {
80
+ display: none;
81
+ }
82
+
83
+ .form-button {
84
+ background-color: #007bff;
85
+ color: white;
86
+ padding: 10px 15px;
87
+ border: none;
88
+ border-radius: 5px;
89
+ cursor: pointer;
90
+ }
91
+
92
+ .form-button:hover {
93
+ background-color: #0056b3;
94
+ }
95
+
96
+ .column-group {
97
+ border: 1px solid #ddd;
98
+ padding: 10px;
99
+ margin-bottom: 10px;
100
+ border-radius: 5px;
101
+ }
102
+
103
+ .remove-column-btn {
104
+ background-color: red;
105
+ color: white;
106
+ border: none;
107
+ padding: 5px;
108
+ cursor: pointer;
109
+ margin-top: 5px;
110
+ }
111
+ </style>
112
+ <script>
113
+ document.addEventListener("DOMContentLoaded", function() {
114
+ const operationSelect = document.getElementById("operation_type");
115
+ const tableNameField = document.getElementById("table_name_field");
116
+ const tableSelectField = document.getElementById("table_select_field");
117
+ const columnsSection = document.getElementById("columns_section");
118
+ const addColumnButton = document.getElementById("add_column");
119
+
120
+ function toggleTableFields() {
121
+ if (operationSelect.value === "Create Table") {
122
+ tableNameField.style.display = "block"; // Show text input for table name
123
+ tableSelectField.style.display = "none"; // Hide dropdown
124
+ columnsSection.style.display = "block"; // Show columns section
125
+ addColumnButton.style.display = "block";
126
+ } else if (operationSelect.value === "Add Column") {
127
+ tableNameField.style.display = "none"; // Hide text input
128
+ tableSelectField.style.display = "block"; // Show dropdown for table selection
129
+ columnsSection.style.display = "block"; // Show columns section
130
+ addColumnButton.style.display = "block";
131
+ } else {
132
+ tableNameField.style.display = "none"; // Hide both for other operations
133
+ tableSelectField.style.display = "none";
134
+ columnsSection.style.display = "none";
135
+ addColumnButton.style.display = "none";
136
+ }
137
+ }
138
+
139
+ operationSelect.addEventListener("change", toggleTableFields);
140
+ toggleTableFields(); // Initial check on page load
141
+
142
+ // Functionality for adding/removing columns dynamically
143
+ addColumnButton.addEventListener("click", function() {
144
+ const columnGroup = document.createElement("div");
145
+ columnGroup.className = "form-group column-group";
146
+ columnGroup.innerHTML = `
147
+ <label class="form-label">Column Name</label>
148
+ <input type="text" name="columns[][name]" class="form-input" placeholder="Enter column name">
149
+
150
+ <label class="form-label">Column Type</label>
151
+ <select name="columns[][type]" class="form-select">
152
+ <option value="string">String</option>
153
+ <option value="integer">Integer</option>
154
+ <option value="boolean">Boolean</option>
155
+ <option value="text">Text</option>
156
+ <option value="date">Date</option>
157
+ <option value="datetime">Datetime</option>
158
+ <option value="jsonb">JSONB</option>
159
+ </select>
160
+
161
+ <label class="form-label">Default Value</label>
162
+ <input type="text" name="columns[][default]" class="form-input" placeholder="Optional default value">
163
+
164
+ <button type="button" class="remove-column form-button">Remove</button>
165
+ `;
166
+
167
+ columnGroup.querySelector(".remove-column").addEventListener("click", function() {
168
+ columnGroup.remove();
169
+ });
170
+
171
+ columnsSection.appendChild(columnGroup);
172
+ });
173
+
174
+ document.querySelectorAll(".remove-column").forEach(button => {
175
+ button.addEventListener("click", function() {
176
+ button.parentElement.remove();
177
+ });
178
+ });
179
+ });
180
+ </script>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "migration/manager"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ MigrationManager::Engine.routes.draw do
2
+ get 'home', to: 'home#index'
3
+ post 'run_migration', to: 'home#run_migration'
4
+
5
+ # Migration Builder UI
6
+ get 'new_migration', to: 'migration_builder#new'
7
+ post 'create_migration', to: 'migration_builder#create'
8
+ end
@@ -0,0 +1,5 @@
1
+ module Migration
2
+ module Manager
3
+ VERSION = "1.0"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require "migration/manager/version"
2
+
3
+ module Migration
4
+ module Manager
5
+ class HomeController < ActionController::Base
6
+ def index
7
+ @text = "Hello, World!"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ require "rails"
2
+ require "rails/engine"
3
+
4
+ module MigrationManager
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace MigrationManager
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ require "rails"
2
+ require "migration_manager/engine"
3
+ module MigrationManager
4
+ # Your module logic here
5
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'lib/migration/manager/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "migration-manager"
5
+ spec.version = Migration::Manager::VERSION
6
+ spec.authors = ["Rajnish mishra"]
7
+ spec.email = ["rajnish.mishra@jarvis.consulting"]
8
+
9
+ spec.summary = %q{Write a short summary, because RubyGems requires one.}
10
+ spec.description = %q{Write a longer description or delete this line.}
11
+ spec.homepage = "https://github.com/rajnish-jarvis"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+ spec.add_dependency "rails", ">= 6.0"
15
+ spec.metadata["homepage_uri"] = "https://github.com/rajnish-jarvis/migration-manager"
16
+ spec.metadata["source_code_uri"] = "https://github.com/rajnish-jarvis/migration-manager"
17
+ spec.metadata["changelog_uri"] = "https://github.com/rajnish-jarvis/migration-manager"
18
+
19
+ # Exclude the .gem file from being listed
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|migration-manager-0.1.0.gem)$}) }
22
+ end
23
+
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+ end
@@ -0,0 +1,11 @@
1
+ require "test_helper"
2
+
3
+ class Migration::ManagerTest < Minitest::Test
4
+ def test_that_it_has_a_version_number
5
+ refute_nil ::Migration::Manager::VERSION
6
+ end
7
+
8
+ def test_it_does_something_useful
9
+ assert false
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
2
+ require "migration/manager"
3
+
4
+ require "minitest/autorun"
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: migration-manager
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Rajnish mishra
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ description: Write a longer description or delete this line.
28
+ email:
29
+ - rajnish.mishra@jarvis.consulting
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".idea/migration-manager.iml"
36
+ - ".idea/modules.xml"
37
+ - ".idea/vcs.xml"
38
+ - ".idea/workspace.xml"
39
+ - ".travis.yml"
40
+ - CODE_OF_CONDUCT.md
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - app/assets/config/manifest.js
47
+ - app/assets/javascripts/migration_manager.js
48
+ - app/assets/stylesheets/migration_manager.css
49
+ - app/controllers/migration_manager/application_controller.rb
50
+ - app/controllers/migration_manager/home_controller.rb
51
+ - app/controllers/migration_manager/migration_builder_controller.rb
52
+ - app/views/migration_manager/home/index.html.erb
53
+ - app/views/migration_manager/migration_builder/new.html.erb
54
+ - bin/console
55
+ - bin/setup
56
+ - config/routes.rb
57
+ - lib/migration/manager.rb
58
+ - lib/migration/manager/version.rb
59
+ - lib/migration_manager.rb
60
+ - lib/migration_manager/engine.rb
61
+ - migration-manager.gemspec
62
+ - test/migration/manager_test.rb
63
+ - test/test_helper.rb
64
+ homepage: https://github.com/rajnish-jarvis
65
+ licenses:
66
+ - MIT
67
+ metadata:
68
+ homepage_uri: https://github.com/rajnish-jarvis/migration-manager
69
+ source_code_uri: https://github.com/rajnish-jarvis/migration-manager
70
+ changelog_uri: https://github.com/rajnish-jarvis/migration-manager
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.3.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.1.6
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Write a short summary, because RubyGems requires one.
90
+ test_files: []