-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
couple_round_tallies
to non-schema_plus
Also, since Rails schema cannot dump views without schema_plus, the view creation is contained in the db/structure.sql file.
- Loading branch information
Showing
4 changed files
with
102 additions
and
113 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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
DROP VIEW IF EXISTS couple_round_tallies; | ||
|
||
CREATE VIEW couple_round_tallies AS | ||
SELECT couples.id AS couple_id, | ||
count(marks.id) AS num_marks, | ||
rounds.id AS round_id | ||
FROM rounds | ||
INNER JOIN sub_rounds ON sub_rounds.round_id = rounds.id | ||
INNER JOIN marks ON marks.sub_round_id = sub_rounds.id | ||
INNER JOIN couples ON couples.id = marks.couple_id | ||
GROUP BY couples.id, rounds.id; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace :db do | ||
namespace :views do | ||
desc "Load views from the views.sql file" | ||
task :load => [:environment, :load_config] do | ||
puts "-- Loading views.sql" | ||
view_file = File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, "views.sql") | ||
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:sql, view_file) | ||
end | ||
end | ||
|
||
# Redefine `:setup` to run `db:views:load` | ||
task :setup do | ||
Rake::Task['db:views:load'].invoke | ||
end | ||
end |