mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
32 lines
747 B
Crystal
32 lines
747 B
Crystal
class RelativePath < MG::Base
|
|
def up : String
|
|
base = Config.current.library_path
|
|
base = base[...-1] if base.ends_with? "/"
|
|
|
|
<<-SQL
|
|
-- update the path column in ids to relative paths
|
|
UPDATE ids
|
|
SET path = REPLACE(path, '#{base}', '');
|
|
|
|
-- update the path column in titles to relative paths
|
|
UPDATE titles
|
|
SET path = REPLACE(path, '#{base}', '');
|
|
SQL
|
|
end
|
|
|
|
def down : String
|
|
base = Config.current.library_path
|
|
base = base[...-1] if base.ends_with? "/"
|
|
|
|
<<-SQL
|
|
-- update the path column in ids to absolute paths
|
|
UPDATE ids
|
|
SET path = '#{base}' || path;
|
|
|
|
-- update the path column in titles to absolute paths
|
|
UPDATE titles
|
|
SET path = '#{base}' || path;
|
|
SQL
|
|
end
|
|
end
|