data_migration_for_rails 0.1.3 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cfb5ac35d2961f41dff545c01c02d8ece214205ef3081d6b0c6a5df6850006e
4
- data.tar.gz: 0232f9a2313abea779ffcec43300eaf4e352c11b9b29c73cef997d83993ed2eb
3
+ metadata.gz: e63b71c83e6d3ad8a7ce1303c1e420a2f5d18b52e3c9ae2c8699dffd7d360d03
4
+ data.tar.gz: 632b9805658b6889ceb6294cd674e9481d744a855467fd3d4530331a5992f725
5
5
  SHA512:
6
- metadata.gz: d2b2c3be6054683d7b62c7a9779f38dde0c30e31d82f92d9df1623eb52d415c24d2236acddda395565be90433c73a7decb6a705b65051920d4ad15b944d63380
7
- data.tar.gz: 80a56ab498446a6ab927509e0abe40cadf4b2b8399194aedbda7bbe60c792a1fb421008fe20d144ba3bda736988414762f6e34a02eaaf0350199ecd2b01df575
6
+ metadata.gz: 3fbd6098d10948bc8c6bcde4b45657d6563b5e26a1ae6c4a0e84c6ea2f8e6e9798201af3a06bd14463ec56a65e0ede49545114fd28ee9dc78d70347ff14601d8
7
+ data.tar.gz: be5e7fc77968f04cf807fc870bbd3e27ae562f1b1306327b4e2465daf769885517e44438cc2c1bcd91a215d5519d46ba4f57545e4b9e5aa86ea5357c9374aa4b
data/README.md CHANGED
@@ -24,7 +24,7 @@ A mountable Rails engine for migrating data between Rails application environmen
24
24
  ### 1. Add to Gemfile
25
25
 
26
26
  ```ruby
27
- gem "data_migration_for_rails", "~> 0.1"
27
+ gem "data_migration_for_rails", "~> 0.1", ">= 0.1.4"
28
28
  ```
29
29
 
30
30
  ### 2. Install and Migrate
@@ -7,7 +7,7 @@ module DataMigration
7
7
  def new
8
8
  authorize @migration_plan, :execute?
9
9
  @filter_params = extract_placeholders_from_plan
10
- @last_export = @migration_plan.migration_executions.export.completed.order(created_at: :desc).first
10
+ @last_export = @migration_plan.migration_executions.export_type.completed.order(created_at: :desc).first
11
11
  end
12
12
 
13
13
  def create
@@ -19,7 +19,7 @@ module DataMigration
19
19
  @action_counts = {}
20
20
 
21
21
  # Only load migration records for import executions
22
- return unless @execution.import?
22
+ return unless @execution.import_type?
23
23
 
24
24
  # Reload association to ensure fresh data
25
25
  @execution.reload
@@ -50,7 +50,7 @@ module DataMigration
50
50
  def download
51
51
  authorize @execution, :download?
52
52
 
53
- unless @execution.completed? && @execution.export? && @execution.file_path.present?
53
+ unless @execution.completed? && @execution.export_type? && @execution.file_path.present?
54
54
  redirect_to @execution, alert: 'Export file not available.'
55
55
  return
56
56
  end
@@ -21,6 +21,7 @@ module DataMigration
21
21
 
22
22
  def create
23
23
  @migration_plan = MigrationPlan.new(migration_plan_params)
24
+ @migration_plan.user = current_user
24
25
  authorize @migration_plan
25
26
 
26
27
  if @migration_plan.save
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Users
4
- class SessionsController < Devise::SessionsController
3
+ module DataMigration
4
+ module Users
5
+ class SessionsController < Devise::SessionsController
5
6
  # Skip CSRF verification for the new action to handle Devise FailureApp redirects
6
7
  skip_before_action :verify_authenticity_token, only: [:new]
7
8
 
@@ -26,5 +27,6 @@ module Users
26
27
  # def configure_sign_in_params
27
28
  # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
28
29
  # end
30
+ end
29
31
  end
30
32
  end
@@ -21,7 +21,7 @@ module DataMigration
21
21
  @user = DataMigrationUser.new(user_params)
22
22
 
23
23
  if @user.save
24
- redirect_to users_path, notice: 'User created successfully.'
24
+ redirect_to '/data_migration/users', notice: 'User created successfully.'
25
25
  else
26
26
  render :new, status: :unprocessable_entity
27
27
  end
@@ -42,7 +42,7 @@ module DataMigration
42
42
  end
43
43
 
44
44
  if @user.update(params_to_update)
45
- redirect_to users_path, notice: 'User updated successfully.'
45
+ redirect_to '/data_migration/users', notice: 'User updated successfully.'
46
46
  else
47
47
  render :edit, status: :unprocessable_entity
48
48
  end
@@ -52,9 +52,9 @@ module DataMigration
52
52
  authorize @user
53
53
 
54
54
  if @user.destroy
55
- redirect_to users_path, notice: 'User deleted successfully.'
55
+ redirect_to '/data_migration/users', notice: 'User deleted successfully.'
56
56
  else
57
- redirect_to users_path, alert: @user.errors.full_messages.join(', ')
57
+ redirect_to '/data_migration/users', alert: @user.errors.full_messages.join(', ')
58
58
  end
59
59
  end
60
60
 
@@ -65,7 +65,7 @@ module DataMigration
65
65
  end
66
66
 
67
67
  def user_params
68
- params.require(:user).permit(:name, :email, :password, :password_confirmation, :role)
68
+ params.require(:data_migration_user).permit(:name, :email, :password, :password_confirmation, :role)
69
69
  end
70
70
  end
71
71
  end
@@ -7,7 +7,7 @@ class MigrationExecution < ApplicationRecord
7
7
  has_many :migration_records, dependent: :destroy
8
8
 
9
9
  # Enums
10
- enum execution_type: { export: 0, import: 1 }
10
+ enum execution_type: { export: 0, import: 1 }, _suffix: :type
11
11
  enum status: { pending: 0, running: 1, completed: 2, failed: 3 }
12
12
 
13
13
  # Validations
@@ -46,7 +46,7 @@
46
46
  <td>
47
47
  <% if execution.stats.present? %>
48
48
  <small>
49
- <% if execution.export? %>
49
+ <% if execution.export_type? %>
50
50
  <%= execution.stats['processed_records'] || 0 %> records
51
51
  <% else %>
52
52
  <span class="text-success"><%= execution.stats['created'] || 0 %></span> /
@@ -59,7 +59,7 @@
59
59
  <td>
60
60
  <div class="btn-group btn-group-sm">
61
61
  <%= link_to "View", execution, class: "btn btn-outline-primary" %>
62
- <% if execution.completed? && execution.export? && execution.file_path.present? %>
62
+ <% if execution.completed? && execution.export_type? && execution.file_path.present? %>
63
63
  <%= link_to "Download", download_migration_execution_path(execution), class: "btn btn-outline-success" %>
64
64
  <% end %>
65
65
  </div>
@@ -64,7 +64,7 @@
64
64
  <!-- Statistics -->
65
65
  <% if @execution.stats.present? %>
66
66
  <div class="row text-center mt-4">
67
- <% if @execution.export? %>
67
+ <% if @execution.export_type? %>
68
68
  <div class="col-md-4">
69
69
  <div class="card">
70
70
  <div class="card-body">
@@ -132,7 +132,7 @@
132
132
  <div class="card bg-light">
133
133
  <div class="card-body">
134
134
  <h4 class="text-success mb-0">
135
- 📎 <%= @execution.stats['processed_attachments'] || 0 %> Attachments <%= @execution.export? ? 'Exported' : 'Imported' %>
135
+ 📎 <%= @execution.stats['processed_attachments'] || 0 %> Attachments <%= @execution.export_type? ? 'Exported' : 'Imported' %>
136
136
  </h4>
137
137
  </div>
138
138
  </div>
@@ -142,7 +142,7 @@
142
142
  <% end %>
143
143
 
144
144
  <!-- Download Export -->
145
- <% if @execution.completed? && @execution.export? && @execution.file_path.present? %>
145
+ <% if @execution.completed? && @execution.export_type? && @execution.file_path.present? %>
146
146
  <div class="d-grid gap-2 mt-4">
147
147
  <%= link_to "📥 Download Export Archive", download_migration_execution_path(@execution), class: "btn btn-success btn-lg" %>
148
148
  </div>
@@ -151,7 +151,7 @@
151
151
  </div>
152
152
 
153
153
  <!-- Migration Records -->
154
- <% if @execution.import? && @execution.migration_records.any? %>
154
+ <% if @execution.import_type? && @execution.migration_records.any? %>
155
155
  <div class="card">
156
156
  <div class="card-header d-flex justify-content-between align-items-center">
157
157
  <h5 class="mb-0">Processed Records</h5>
@@ -1,4 +1,4 @@
1
- <%= form_with(model: user, url: user.new_record? ? users_path : user_path(user), local: true) do |form| %>
1
+ <%= form_with(model: user, url: user.new_record? ? '/data_migration/users' : '/data_migration/users/' + user.id.to_s, local: true) do |form| %>
2
2
  <% if user.errors.any? %>
3
3
  <div class="alert alert-danger">
4
4
  <h4><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h4>
@@ -45,5 +45,5 @@
45
45
  </div>
46
46
 
47
47
  <%= form.submit user.new_record? ? "Create User" : "Update User", class: "btn btn-primary" %>
48
- <%= link_to "Cancel", users_path, class: "btn btn-secondary" %>
48
+ <%= link_to "Cancel", '/data_migration/users', class: "btn btn-secondary" %>
49
49
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <div class="d-flex justify-content-between align-items-center mb-4">
2
2
  <h1>Users</h1>
3
- <%= link_to "New User", new_user_path, class: "btn btn-primary" %>
3
+ <%= link_to "New User", '/data_migration/users/new', class: "btn btn-primary" %>
4
4
  </div>
5
5
 
6
6
  <div class="table-responsive">
@@ -26,9 +26,9 @@
26
26
  </td>
27
27
  <td><%= time_ago_in_words(user.created_at) %> ago</td>
28
28
  <td>
29
- <%= link_to "Edit", edit_user_path(user), class: "btn btn-sm btn-outline-warning" %>
29
+ <%= link_to "Edit", '/data_migration/users/' + user.id.to_s + '/edit', class: "btn btn-sm btn-outline-warning" %>
30
30
  <% if user != current_user %>
31
- <%= button_to "Delete", user_path(user),
31
+ <%= button_to "Delete", '/data_migration/users/' + user.id.to_s,
32
32
  method: :delete,
33
33
  class: "btn btn-sm btn-outline-danger",
34
34
  data: { confirm: "Are you sure?" } %>
@@ -22,15 +22,15 @@
22
22
 
23
23
  <% if policy(@user).change_role? && @user.id != current_user.id %>
24
24
  <div class="btn-group btn-group-sm ms-3">
25
- <%= button_to "Make Viewer", change_role_user_path(@user, role: :viewer),
25
+ <%= button_to "Make Viewer", '/data_migration/users/' + @user.id.to_s + '?role=viewer',
26
26
  method: :patch,
27
27
  class: "btn btn-sm btn-outline-secondary #{'active' if @user.viewer?}",
28
28
  data: { confirm: "Change #{@user.email} to Viewer?" } %>
29
- <%= button_to "Make Operator", change_role_user_path(@user, role: :operator),
29
+ <%= button_to "Make Operator", '/data_migration/users/' + @user.id.to_s + '?role=operator',
30
30
  method: :patch,
31
31
  class: "btn btn-sm btn-outline-warning #{'active' if @user.operator?}",
32
32
  data: { confirm: "Change #{@user.email} to Operator?" } %>
33
- <%= button_to "Make Admin", change_role_user_path(@user, role: :admin),
33
+ <%= button_to "Make Admin", '/data_migration/users/' + @user.id.to_s + '?role=admin',
34
34
  method: :patch,
35
35
  class: "btn btn-sm btn-outline-danger #{'active' if @user.admin?}",
36
36
  data: { confirm: "Change #{@user.email} to Admin?" } %>
@@ -126,7 +126,7 @@
126
126
 
127
127
  <div class="card mt-3">
128
128
  <div class="card-body">
129
- <%= link_to "← Back to Users", users_path, class: "btn btn-secondary w-100" %>
129
+ <%= link_to "← Back to Users", '/data_migration/users', class: "btn btn-secondary w-100" %>
130
130
  </div>
131
131
  </div>
132
132
  </div>
@@ -16,7 +16,7 @@
16
16
  </li>
17
17
  <% if current_user.admin? %>
18
18
  <li class="nav-item">
19
- <%= link_to "Users", users_path, class: "nav-link" %>
19
+ <%= link_to "Users", '/data_migration/users', class: "nav-link" %>
20
20
  </li>
21
21
  <% end %>
22
22
  </ul>
data/config/routes.rb CHANGED
@@ -4,7 +4,7 @@ DataMigration::Engine.routes.draw do
4
4
  # Devise routes for DataMigrationUser
5
5
  devise_for :users, class_name: 'DataMigrationUser',
6
6
  controllers: {
7
- sessions: 'users/sessions'
7
+ sessions: 'data_migration/users/sessions'
8
8
  },
9
9
  path: '',
10
10
  path_names: {
@@ -15,7 +15,7 @@ DataMigration::Engine.routes.draw do
15
15
 
16
16
  # Define root path with devise_scope
17
17
  devise_scope :user do
18
- root to: 'users/sessions#new'
18
+ root to: 'data_migration/users/sessions#new'
19
19
 
20
20
  # Registration routes for password changes only (edit/update)
21
21
  resource :registration,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DataMigration
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_migration_for_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vaibhav Rokkam
@@ -190,8 +190,8 @@ files:
190
190
  - app/controllers/data_migration/migration_executions_controller.rb
191
191
  - app/controllers/data_migration/migration_plans_controller.rb
192
192
  - app/controllers/data_migration/migration_steps_controller.rb
193
+ - app/controllers/data_migration/users/sessions_controller.rb
193
194
  - app/controllers/data_migration/users_controller.rb
194
- - app/controllers/users/sessions_controller.rb
195
195
  - app/helpers/data_migration/application_helper.rb
196
196
  - app/jobs/application_job.rb
197
197
  - app/jobs/export_job.rb
@@ -234,21 +234,17 @@ files:
234
234
  - app/views/data_migration/users/edit.html.erb
235
235
  - app/views/data_migration/users/index.html.erb
236
236
  - app/views/data_migration/users/new.html.erb
237
+ - app/views/data_migration/users/registrations/edit.html.erb
238
+ - app/views/data_migration/users/sessions/new.html.erb
239
+ - app/views/data_migration/users/shared/_error_messages.html.erb
240
+ - app/views/data_migration/users/shared/_links.html.erb
237
241
  - app/views/data_migration/users/show.html.erb
238
242
  - app/views/layouts/_navbar.html.erb
239
243
  - app/views/layouts/data_migration.html.erb
240
244
  - app/views/layouts/mailer.html.erb
241
245
  - app/views/layouts/mailer.text.erb
242
- - app/views/users/registrations/edit.html.erb
243
- - app/views/users/sessions/new.html.erb
244
- - app/views/users/shared/_error_messages.html.erb
245
- - app/views/users/shared/_links.html.erb
246
- - config/initializers/assets.rb
247
- - config/initializers/content_security_policy.rb
248
246
  - config/initializers/devise.rb
249
247
  - config/initializers/filter_parameter_logging.rb
250
- - config/initializers/inflections.rb
251
- - config/initializers/permissions_policy.rb
252
248
  - config/initializers/warden.rb
253
249
  - config/locales/devise.en.yml
254
250
  - config/locales/en.yml
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Version of your assets, change this if you want to expire all your assets.
6
- Rails.application.config.assets.version = '1.0'
7
-
8
- # Add additional assets to the asset load path.
9
- # Rails.application.config.assets.paths << Emoji.images_path
10
-
11
- # Precompile additional assets.
12
- # application.js, application.css, and all non-JS/CSS in the app/assets
13
- # folder are already added.
14
- # Rails.application.config.assets.precompile += %w( admin.js admin.css )
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Define an application-wide content security policy.
6
- # See the Securing Rails Applications Guide for more information:
7
- # https://guides.rubyonrails.org/security.html#content-security-policy-header
8
-
9
- # Rails.application.configure do
10
- # config.content_security_policy do |policy|
11
- # policy.default_src :self, :https
12
- # policy.font_src :self, :https, :data
13
- # policy.img_src :self, :https, :data
14
- # policy.object_src :none
15
- # policy.script_src :self, :https
16
- # policy.style_src :self, :https
17
- # # Specify URI for violation reports
18
- # # policy.report_uri "/csp-violation-report-endpoint"
19
- # end
20
- #
21
- # # Generate session nonces for permitted importmap, inline scripts, and inline styles.
22
- # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
23
- # config.content_security_policy_nonce_directives = %w(script-src style-src)
24
- #
25
- # # Report violations without enforcing the policy.
26
- # # config.content_security_policy_report_only = true
27
- # end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Add new inflection rules using the following format. Inflections
6
- # are locale specific, and you may define rules for as many different
7
- # locales as you wish. All of these examples are active by default:
8
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
9
- # inflect.plural /^(ox)$/i, "\\1en"
10
- # inflect.singular /^(ox)en/i, "\\1"
11
- # inflect.irregular "person", "people"
12
- # inflect.uncountable %w( fish sheep )
13
- # end
14
-
15
- # These inflection rules are supported but not enabled by default:
16
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
17
- # inflect.acronym "RESTful"
18
- # end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Define an application-wide HTTP permissions policy. For further
6
- # information see: https://developers.google.com/web/updates/2018/06/feature-policy
7
-
8
- # Rails.application.config.permissions_policy do |policy|
9
- # policy.camera :none
10
- # policy.gyroscope :none
11
- # policy.microphone :none
12
- # policy.usb :none
13
- # policy.fullscreen :self
14
- # policy.payment :self, "https://secure.example.com"
15
- # end