Skip to content

Commit

Permalink
Use Sequel instead of custom raw SQL
Browse files Browse the repository at this point in the history
- this allows bundle exec rake to work with mysql
- it loses database constraints, which are now only enforced by the renew function in AsgLatestUpdate
- would be nice to keep the database constraint, but we couldn't figure out why the sequel migration didn't like the CREATE UNIQUE INDEX line for mysql (it was fine with postgres)

Co-authored-by: Michael Oleske <[email protected]>
Co-authored-by: David Alvarado <[email protected]>
  • Loading branch information
2 people authored and MerricdeLauney committed Jun 27, 2022
1 parent 54444da commit 7cb7e88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 41 deletions.
27 changes: 4 additions & 23 deletions db/migrations/20220601183937_create_asg_lastest_updates.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
Sequel.migration do
up do
if database_type == :postgres
run <<-SQL
CREATE TABLE asg_timestamps (
id INT PRIMARY KEY DEFAULT 1,
last_update TIMESTAMP
);
CREATE UNIQUE INDEX asg_change_singleton ON asg_timestamps ((true));
SQL
else
run <<-SQL
CREATE TABLE asg_timestamps (
id INT PRIMARY KEY DEFAULT 1,
last_update TIMESTAMP,
unique_value ENUM('lockme') NOT NULL DEFAULT 'lockme'
);
CREATE UNIQUE INDEX asg_change_singleton ON asg_timestamps (unique_value);
SQL
change do
create_table :asg_timestamps do
primary_key name: :id
Timestamp :last_update
end
end

down do
drop_table(:asg_timestamps)
end
end
18 changes: 0 additions & 18 deletions spec/migrations/20220601183937_create_asg_latest_updates_spec.rb

This file was deleted.

0 comments on commit 7cb7e88

Please sign in to comment.