Skip to content

Commit c73b250

Browse files
authored
Revert "Delete migrations from UI (#132)" (#138)
This reverts commit 0ed25aa.
1 parent b1d62b8 commit c73b250

File tree

11 files changed

+0
-96
lines changed

11 files changed

+0
-96
lines changed

app/controllers/actual_db_schema/migrations_controller.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ def migrate
2222
redirect_to migrations_path
2323
end
2424

25-
def delete
26-
handle_delete(params[:id], params[:database])
27-
redirect_to migrations_path
28-
end
29-
3025
private
3126

3227
def handle_rollback(id, database)
@@ -43,13 +38,6 @@ def handle_migrate(id, database)
4338
flash[:alert] = e.message
4439
end
4540

46-
def handle_delete(id, database)
47-
ActualDbSchema::Migration.instance.delete(id, database)
48-
flash[:notice] = "Migration #{id} was successfully deleted."
49-
rescue StandardError => e
50-
flash[:alert] = e.message
51-
end
52-
5341
helper_method def migrations
5442
@migrations ||= ActualDbSchema::Migration.instance.all
5543
query = params[:query].to_s.strip.downcase

app/controllers/actual_db_schema/phantom_migrations_controller.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ def rollback_all
2222
redirect_to phantom_migrations_path
2323
end
2424

25-
def delete
26-
handle_delete(params[:id], params[:database])
27-
redirect_to phantom_migrations_path
28-
end
29-
3025
private
3126

3227
def handle_rollback(id, database)
@@ -43,13 +38,6 @@ def handle_rollback_all
4338
flash[:alert] = e.message
4439
end
4540

46-
def handle_delete(id, database)
47-
ActualDbSchema::Migration.instance.delete(id, database)
48-
flash[:notice] = "Migration #{id} was successfully deleted."
49-
rescue StandardError => e
50-
flash[:alert] = e.message
51-
end
52-
5341
helper_method def phantom_migrations
5442
@phantom_migrations ||= ActualDbSchema::Migration.instance.all_phantom
5543
end

app/views/actual_db_schema/migrations/index.html.erb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@
6666
method: :post,
6767
class: 'button migration-action',
6868
style: ('display: none;' if migration[:status] == "up" || migration[:phantom]) %>
69-
<%= button_to '✖ Delete',
70-
delete_migration_path(id: migration[:version], database: migration[:database]),
71-
method: :post,
72-
data: { confirm: 'Are you sure you want to delete this migration?' },
73-
class: 'button migration-action' %>
7469
</div>
7570
</td>
7671
</tr>

app/views/actual_db_schema/migrations/show.html.erb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@
5252
method: :post,
5353
class: 'button migration-action',
5454
style: ('display: none;' if migration[:status] == "up" || migration[:phantom]) %>
55-
<%= button_to '✖ Delete',
56-
delete_migration_path(id: migration[:version], database: migration[:database]),
57-
method: :post,
58-
data: { confirm: 'Are you sure you want to delete this migration?' },
59-
class: 'button migration-action' %>
6055
</div>
6156
</div>
6257
</body>

app/views/actual_db_schema/phantom_migrations/index.html.erb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@
5353
rollback_phantom_migration_path(id: migration[:version], database: migration[:database]),
5454
method: :post,
5555
class: 'button migration-action' %>
56-
<%= button_to '✖ Delete',
57-
delete_phantom_migration_path(id: migration[:version], database: migration[:database]),
58-
method: :post,
59-
data: { confirm: 'Are you sure you want to delete this migration?' },
60-
class: 'button migration-action' %>
6156
</div>
6257
</td>
6358
</tr>

app/views/actual_db_schema/phantom_migrations/show.html.erb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
rollback_phantom_migration_path(id: params[:id], database: params[:database]),
4747
method: :post,
4848
class: 'button migration-action' %>
49-
<%= button_to '✖ Delete',
50-
delete_phantom_migration_path(id: params[:id], database: params[:database]),
51-
method: :post,
52-
data: { confirm: 'Are you sure you want to delete this migration?' },
53-
class: 'button migration-action' %>
5449
</div>
5550
</div>
5651
</body>

app/views/actual_db_schema/shared/_js.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
migrationActions.forEach(button => {
66
button.addEventListener('click', function(event) {
7-
const confirmMessage = button.dataset.confirm;
8-
if (confirmMessage && !confirm(confirmMessage)) {
9-
event.preventDefault();
10-
return;
11-
}
12-
137
const originalText = button.value;
148
button.value = 'Loading...';
159
disableButtons();

config/routes.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
member do
66
post :rollback
77
post :migrate
8-
post :delete
98
end
109
end
1110
resources :phantom_migrations, only: %i[index show] do
1211
member do
1312
post :rollback
14-
post :delete
1513
end
1614
collection do
1715
post :rollback_all

lib/actual_db_schema/migration.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ def migrate(version, database)
7373
end
7474
end
7575

76-
def delete(version, database)
77-
MigrationContext.instance.each do
78-
next unless ActualDbSchema.db_config[:database] == database
79-
80-
ActiveRecord::Base.connection.execute("DELETE FROM schema_migrations WHERE version = '#{version}'")
81-
break
82-
end
83-
end
84-
8576
private
8677

8778
def build_migration_struct(status, migration)

test/controllers/actual_db_schema/migrations_controller_test.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def routes_setup
2626
get "/rails/migration/:id" => "actual_db_schema/migrations#show", as: "migration"
2727
post "/rails/migration/:id/rollback" => "actual_db_schema/migrations#rollback", as: "rollback_migration"
2828
post "/rails/migration/:id/migrate" => "actual_db_schema/migrations#migrate", as: "migrate_migration"
29-
post "/rails/migration/:id/delete" => "actual_db_schema/migrations#delete", as: "delete_migration"
3029
end
3130
ActualDbSchema::MigrationsController.include(@routes.url_helpers)
3231
end
@@ -170,21 +169,5 @@ def down
170169
end
171170
assert_select ".flash", text: "Migration 20130906111511 was successfully rolled back."
172171
end
173-
174-
test "POST #delete removes migration record" do
175-
version = "20130906111511"
176-
sql = "SELECT version FROM schema_migrations WHERE version = '#{version}'"
177-
ActiveRecord::Base.establish_connection(TestingState.db_config["primary"])
178-
179-
assert_not_nil ActiveRecord::Base.connection.select_value(sql)
180-
post :delete, params: { id: version, database: @utils.primary_database }
181-
assert_response :redirect
182-
get :index
183-
assert_select "table" do |table|
184-
assert_no_match "20130906111511", table.text
185-
end
186-
assert_select ".flash", text: "Migration 20130906111511 was successfully deleted."
187-
assert_nil ActiveRecord::Base.connection.select_value(sql)
188-
end
189172
end
190173
end

0 commit comments

Comments
 (0)