Skip to content

Commit

Permalink
Seed announcement views
Browse files Browse the repository at this point in the history
  • Loading branch information
NuckChorris committed Mar 16, 2021
1 parent db765c2 commit 6459a31
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions db/migrate/20210316035000_seed_site_announcement_views.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class SeedSiteAnnouncementViews < ActiveRecord::Migration[5.2]
def up
execute 'SET statement_timeout TO DEFAULT'
execute <<-SQL
INSERT INTO site_announcement_views (user_id, announcement_id)
SELECT
users.id AS user_id,
site_announcements.id AS announcement_id
FROM users
CROSS JOIN site_announcements
ON CONFLICT DO NOTHING;
SQL
end

def down
execute 'TRUNCATE site_announcement_views'
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2021_03_05_232334) do
ActiveRecord::Schema.define(version: 2021_03_16_035000) do

# These are extensions that must be enabled in order to support this database
enable_extension "citext"
Expand Down

0 comments on commit 6459a31

Please sign in to comment.