-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverting proof of concept TotK database migrations
since it does not match new data. Added helpful gems, migration down/rollback code, and doc, keeping the old files to use as future samples. No better ActiveRecord code since we don't have models classes for tables.. Thought pry had an auto require feature usable from the gemfile that was largely applicable =/..
- Loading branch information
Showing
6 changed files
with
139 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 29 additions & 1 deletion
30
dev/db/migrate/disabled/20230405204517_container_add_basic_tot_k_support.rb.disabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
class ContainerAddBasicTotKSupport < ActiveRecord::Migration[7.0] | ||
def database | ||
connection.instance_variable_get(:@config)[:database] | ||
end | ||
|
||
def up | ||
execute <<-SQL | ||
INSERT INTO `container` (`short_name`, `name`, `icon`) VALUES ('TotK','Tears of the Kingdom', 'Tears-of-the-Kingdom'); | ||
INSERT INTO `container` (`id`, `short_name`, `name`, `icon`) VALUES (20, 'TotK','Tears of the Kingdom', 'Tears-of-the-Kingdom'); | ||
SQL | ||
end | ||
def down | ||
execute <<-SQL | ||
DELETE FROM `container` | ||
WHERE `id` = 20; | ||
; | ||
SQL | ||
|
||
aiValue = ( | ||
execute <<-SQL | ||
SELECT `AUTO_INCREMENT` | ||
FROM `INFORMATION_SCHEMA`.`TABLES` | ||
WHERE `TABLE_SCHEMA` = '#{database}' | ||
AND `TABLE_NAME` = 'container' | ||
LIMIT 1 | ||
; | ||
SQL | ||
).first.first | ||
contentEntryAmount = 1 | ||
execute <<-SQL | ||
ALTER TABLE `container` | ||
AUTO_INCREMENT=#{aiValue - contentEntryAmount} | ||
; | ||
SQL | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters