migration-manager 1.0 → 1.1
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 +4 -4
- data/.idea/migration-manager.iml +28 -0
- data/.idea/workspace.xml +27 -4
- data/README.md +57 -17
- data/app/controllers/migration_manager/home_controller.rb +3 -2
- data/app/controllers/migration_manager/migration_builder_controller.rb +24 -8
- data/app/views/migration_manager/migration_builder/new.html.erb +1 -1
- data/lib/migration/manager/version.rb +1 -1
- data/migration-manager.gemspec +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ae2abec6fecee339acc96b79ebc1e407a00c6bdf8f783a376a02a85946572b
|
4
|
+
data.tar.gz: 7aab8865da3dafbe23af6a93dce9a4005328f1fd81178f88e528defd99bd5e39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30e7903326d5230878366e09be7fe7b17d782af53777185a72bc8c7523962553428b4bf8fed17d29f40dee6d025157480812458e3f593de5f138302601cccbc
|
7
|
+
data.tar.gz: 1ec247f69cfb1ecd533b9e356e6d778f1ddeb599427792b3de733169120077881315f46ac897946e70f84f7280b454e1a6d650258caa96fdbe28d1e126db88a8
|
data/.idea/migration-manager.iml
CHANGED
@@ -74,4 +74,32 @@
|
|
74
74
|
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, RVM: ruby-2.7.8) [gem]" level="application" />
|
75
75
|
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.6.18, RVM: ruby-2.7.8) [gem]" level="application" />
|
76
76
|
</component>
|
77
|
+
<component name="RakeTasksCache-v2">
|
78
|
+
<option name="myRootTask">
|
79
|
+
<RakeTaskImpl id="rake">
|
80
|
+
<subtasks>
|
81
|
+
<RakeTaskImpl description="Build migration-manager-1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
82
|
+
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
83
|
+
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
84
|
+
<RakeTaskImpl description="Build and install migration-manager-1.0.gem into system gems" fullCommand="install" id="install" />
|
85
|
+
<RakeTaskImpl id="install">
|
86
|
+
<subtasks>
|
87
|
+
<RakeTaskImpl description="Build and install migration-manager-1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
88
|
+
</subtasks>
|
89
|
+
</RakeTaskImpl>
|
90
|
+
<RakeTaskImpl description="Create tag v1.0 and build and push migration-manager-1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
91
|
+
<RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
|
92
|
+
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
93
|
+
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
94
|
+
<RakeTaskImpl id="release">
|
95
|
+
<subtasks>
|
96
|
+
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
97
|
+
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
98
|
+
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
99
|
+
</subtasks>
|
100
|
+
</RakeTaskImpl>
|
101
|
+
</subtasks>
|
102
|
+
</RakeTaskImpl>
|
103
|
+
</option>
|
104
|
+
</component>
|
77
105
|
</module>
|
data/.idea/workspace.xml
CHANGED
@@ -5,8 +5,7 @@
|
|
5
5
|
</component>
|
6
6
|
<component name="ChangeListManager">
|
7
7
|
<list default="true" id="884633e9-4c9d-4908-ac6b-367ad6beb5f1" name="Changes" comment="Final changes">
|
8
|
-
<change beforePath="$PROJECT_DIR
|
9
|
-
<change beforePath="$PROJECT_DIR$/lib/migration/manager/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/migration/manager/version.rb" afterDir="false" />
|
8
|
+
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
10
9
|
</list>
|
11
10
|
<option name="SHOW_DIALOG" value="false" />
|
12
11
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
@@ -89,7 +88,7 @@
|
|
89
88
|
<workItem from="1739209274970" duration="1301000" />
|
90
89
|
<workItem from="1739690025336" duration="1414000" />
|
91
90
|
<workItem from="1739691571017" duration="1889000" />
|
92
|
-
<workItem from="1739694359841" duration="
|
91
|
+
<workItem from="1739694359841" duration="15485000" />
|
93
92
|
</task>
|
94
93
|
<task id="LOCAL-00001" summary="testing">
|
95
94
|
<option name="closed" value="true" />
|
@@ -291,7 +290,31 @@
|
|
291
290
|
<option name="project" value="LOCAL" />
|
292
291
|
<updated>1739710042104</updated>
|
293
292
|
</task>
|
294
|
-
<
|
293
|
+
<task id="LOCAL-00026" summary="Final changes">
|
294
|
+
<option name="closed" value="true" />
|
295
|
+
<created>1739710387057</created>
|
296
|
+
<option name="number" value="00026" />
|
297
|
+
<option name="presentableId" value="LOCAL-00026" />
|
298
|
+
<option name="project" value="LOCAL" />
|
299
|
+
<updated>1739710387057</updated>
|
300
|
+
</task>
|
301
|
+
<task id="LOCAL-00027" summary="Final changes">
|
302
|
+
<option name="closed" value="true" />
|
303
|
+
<created>1739713615494</created>
|
304
|
+
<option name="number" value="00027" />
|
305
|
+
<option name="presentableId" value="LOCAL-00027" />
|
306
|
+
<option name="project" value="LOCAL" />
|
307
|
+
<updated>1739713615494</updated>
|
308
|
+
</task>
|
309
|
+
<task id="LOCAL-00028" summary="Final changes">
|
310
|
+
<option name="closed" value="true" />
|
311
|
+
<created>1739713855090</created>
|
312
|
+
<option name="number" value="00028" />
|
313
|
+
<option name="presentableId" value="LOCAL-00028" />
|
314
|
+
<option name="project" value="LOCAL" />
|
315
|
+
<updated>1739713855090</updated>
|
316
|
+
</task>
|
317
|
+
<option name="localTasksCounter" value="29" />
|
295
318
|
<servers />
|
296
319
|
</component>
|
297
320
|
<component name="TypeScriptGeneratedFilesManager">
|
data/README.md
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# Migration::Manager
|
1
|
+
# 🚀 Migration::Manager
|
2
2
|
|
3
|
-
|
3
|
+
Migration Manager is a Ruby on Rails gem that provides a web interface for managing database migrations. It allows you to view migration statuses, run pending migrations, create new tables with multiple columns, and update existing tables by adding new columns.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
## Installation
|
5
|
+
## 🔧 Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
10
8
|
|
@@ -14,31 +12,73 @@ gem 'migration-manager'
|
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
17
|
-
|
15
|
+
```sh
|
16
|
+
$ bundle install
|
17
|
+
```
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
|
21
|
+
```sh
|
22
|
+
$ gem install migration-manager
|
23
|
+
```
|
24
|
+
|
25
|
+
## ⚙️ Configuration
|
26
|
+
|
27
|
+
To use this gem, you must remove or disable the following configuration in your environment files (development, production, or test):
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
config.active_record.migration_error = :page_load # Remove or set to false
|
31
|
+
```
|
32
|
+
|
33
|
+
### 🔒 Authentication
|
34
|
+
Set up authentication by defining the following environment variables:
|
35
|
+
|
36
|
+
```sh
|
37
|
+
export MIGRATION_MANAGER_USER=admin
|
38
|
+
export MIGRATION_MANAGER_PASSWORD=password
|
39
|
+
```
|
40
|
+
|
41
|
+
These credentials will be required to access the Migration Manager interface securely.
|
42
|
+
|
43
|
+
## 📌 Usage
|
22
44
|
|
23
|
-
|
45
|
+
### 📍 Mounting in Routes
|
24
46
|
|
25
|
-
|
47
|
+
To mount the Migration Manager in your Rails application, add this line to your `config/routes.rb` file:
|
26
48
|
|
27
|
-
|
49
|
+
```ruby
|
50
|
+
mount MigrationManager::Engine, at: "/migration_manager"
|
51
|
+
```
|
28
52
|
|
29
|
-
|
53
|
+
For now, you must also explicitly require the gem in your application:
|
30
54
|
|
31
|
-
|
55
|
+
```ruby
|
56
|
+
require 'migration_manager'
|
57
|
+
```
|
32
58
|
|
33
|
-
|
59
|
+
✅ We are working on making this requirement unnecessary in future versions.
|
34
60
|
|
35
|
-
|
61
|
+
## ✨ Features
|
36
62
|
|
63
|
+
- ✅ **View all migration statuses** – See pending and applied migrations.
|
64
|
+
- ✅ **Run pending migrations** – Apply database changes directly from the interface.
|
65
|
+
- ✅ **Create tables with multiple columns** – Generate new tables with configurable columns.
|
66
|
+
- ✅ **Update existing tables** – Add new columns to existing tables with ease.
|
67
|
+
- ✅ **Secure access** – Authentication required via environment variables.
|
37
68
|
|
38
|
-
##
|
69
|
+
## 📌 Deployment Considerations
|
70
|
+
|
71
|
+
When deploying to production or staging, migrations must be manually run on the deployment server console. Alternatively, you can set up a trigger on the server to automate migration execution.
|
72
|
+
|
73
|
+
## 🤝 Contributing
|
74
|
+
|
75
|
+
Bug reports and pull requests are welcome on GitHub at [Migration Manager Repository](https://github.com/[USERNAME]/migration-manager). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/migration-manager/blob/master/CODE_OF_CONDUCT.md).
|
76
|
+
|
77
|
+
## 📜 License
|
39
78
|
|
40
79
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
80
|
|
42
|
-
## Code of Conduct
|
81
|
+
## 📏 Code of Conduct
|
82
|
+
|
83
|
+
Everyone interacting in the Migration::Manager project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/migration-manager/blob/master/CODE_OF_CONDUCT.md).
|
43
84
|
|
44
|
-
Everyone interacting in the Migration::Manager project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/migration-manager/blob/master/CODE_OF_CONDUCT.md).
|
@@ -17,9 +17,10 @@ module MigrationManager
|
|
17
17
|
|
18
18
|
def run_migration
|
19
19
|
version = params[:version]
|
20
|
-
|
21
20
|
if version.present?
|
22
|
-
|
21
|
+
migrations_paths = ActiveRecord::Migrator.migrations_paths
|
22
|
+
context = ActiveRecord::MigrationContext.new(migrations_paths, ActiveRecord::SchemaMigration)
|
23
|
+
context.up(version.to_i)
|
23
24
|
redirect_to "#{request.base_url}/migration_manager/home", notice: "Migration #{version} successfully run.!"
|
24
25
|
else
|
25
26
|
redirect_to "#{request.base_url}/migration_manager/home", alert: "Invalid migration version."
|
@@ -5,12 +5,17 @@ module MigrationManager
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def create
|
8
|
-
migration_name = params[:migration_name].presence || "custom_migration"
|
9
8
|
operation = params[:operation] # "create_table" or "alter_table"
|
10
9
|
table_name = params[:table_name].presence
|
11
10
|
columns = params[:columns] || []
|
12
11
|
|
13
|
-
|
12
|
+
return redirect_to request.referer, alert: "Table name is required" if table_name.blank?
|
13
|
+
|
14
|
+
migration_name = generate_migration_name(operation, table_name, columns)
|
15
|
+
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
|
16
|
+
formatted_file_name = migration_name.underscore
|
17
|
+
|
18
|
+
file_name = "#{timestamp}_#{formatted_file_name}.rb"
|
14
19
|
file_path = Rails.root.join("db/migrate/#{file_name}")
|
15
20
|
|
16
21
|
migration_content = generate_migration_content(migration_name, operation, table_name, columns)
|
@@ -22,14 +27,25 @@ module MigrationManager
|
|
22
27
|
|
23
28
|
private
|
24
29
|
|
30
|
+
def generate_migration_name(operation, table, columns)
|
31
|
+
if operation == "create_table"
|
32
|
+
"Create#{table.singularize.camelize}"
|
33
|
+
elsif operation == "alter_table" && columns.any?
|
34
|
+
column_names = columns.map { |col| col[:name].camelize }.join("And")
|
35
|
+
"Add#{column_names}To#{table.camelize}"
|
36
|
+
else
|
37
|
+
"Update#{table.camelize}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
25
41
|
def generate_migration_content(name, operation, table, columns)
|
26
42
|
<<~RUBY
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
43
|
+
class #{name} < ActiveRecord::Migration[7.0]
|
44
|
+
def change
|
45
|
+
#{operation == "create_table" ? create_table_code(table, columns) : alter_table_code(table, columns)}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
RUBY
|
33
49
|
end
|
34
50
|
|
35
51
|
def create_table_code(table, columns)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<div class="form-group">
|
7
7
|
<label class="form-label">Operation Type</label>
|
8
|
-
<%= f.select :operation, ['Create Table', 'Add Column'
|
8
|
+
<%= f.select :operation, ['Create Table', 'Add Column'], {}, id: "operation_type", class: "form-select" %>
|
9
9
|
</div>
|
10
10
|
|
11
11
|
<!-- Table Name Field (Shown for Create Table) -->
|
data/migration-manager.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Rajnish mishra"]
|
7
7
|
spec.email = ["rajnish.mishra@jarvis.consulting"]
|
8
8
|
|
9
|
-
spec.summary = %q{
|
9
|
+
spec.summary = %q{Migration Manager is a Ruby on Rails gem that provides a web interface for managing database migrations. It allows you to view migration statuses, run pending migrations, create new tables with multiple columns, and update existing tables by adding new columns.}
|
10
10
|
spec.description = %q{Write a longer description or delete this line.}
|
11
11
|
spec.homepage = "https://github.com/rajnish-jarvis"
|
12
12
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajnish mishra
|
@@ -86,5 +86,8 @@ requirements: []
|
|
86
86
|
rubygems_version: 3.1.6
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
|
-
summary:
|
89
|
+
summary: Migration Manager is a Ruby on Rails gem that provides a web interface for
|
90
|
+
managing database migrations. It allows you to view migration statuses, run pending
|
91
|
+
migrations, create new tables with multiple columns, and update existing tables
|
92
|
+
by adding new columns.
|
90
93
|
test_files: []
|