diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cd6939e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "db/groupdate"] + path = db/groupdate + url = https://github.com/ankane/groupdate.sql diff --git a/db/groupdate b/db/groupdate new file mode 160000 index 0000000..e8eaa5b --- /dev/null +++ b/db/groupdate @@ -0,0 +1 @@ +Subproject commit e8eaa5b42d9e0ccd1628240a8b86ceb975ed4205 diff --git a/db/migrate/20220324131233_groupdate.rb b/db/migrate/20220324131233_groupdate.rb new file mode 100644 index 0000000..60c9c9b --- /dev/null +++ b/db/migrate/20220324131233_groupdate.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# Instala las funciones de agrupamiento por fecha +class Groupdate < ActiveRecord::Migration[6.1] + def up + groupdate = File.read(Rails.root.join('db', 'groupdate', 'postgresql', 'install.sql')).sub(/(BEGIN|COMMIT);/, '' + ActiveRecord::Base.connection.execute(groupdate) + end + + def down + groupdate = File.read(Rails.root.join('db', 'groupdate', 'postgresql', 'uninstall.sql')).sub(/(BEGIN|COMMIT);/, '' + ActiveRecord::Base.connection.execute(groupdate) + end +end