PHP Classes

File: SQL File

Recommend this page to a friend!
  Packages of Matthew Asham   Binkterm PHP   database/migrations/v1.11.0.50_interest_echo_sources.sql   Download  
File: database/migrations/v1.11.0.50_interest_echo_sources.sql
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Binkterm PHP
Bulletin board system based on the Web
Author: By
Last change:
Date: 5 days ago
Size: 1,087 bytes
 

Contents

Class file image Download
-- Migration: 1.11.0.50 - Interest echo area source tracking -- -- Replaces the single interest_id FK on user_echoarea_subscriptions with a -- proper junction table so an echo area that belongs to multiple interests -- is handled correctly: unsubscribing from one interest only removes the -- echo area subscription when no other subscribed interest also covers it. CREATE TABLE IF NOT EXISTS user_echoarea_interest_sources ( user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, echoarea_id INTEGER NOT NULL REFERENCES echoareas(id) ON DELETE CASCADE, interest_id INTEGER NOT NULL REFERENCES interests(id) ON DELETE CASCADE, PRIMARY KEY (user_id, echoarea_id, interest_id) ); CREATE INDEX IF NOT EXISTS idx_ueis_user_interest ON user_echoarea_interest_sources(user_id, interest_id); -- Backfill from existing interest-sourced subscriptions. INSERT INTO user_echoarea_interest_sources (user_id, echoarea_id, interest_id) SELECT user_id, echoarea_id, interest_id FROM user_echoarea_subscriptions WHERE interest_id IS NOT NULL ON CONFLICT DO NOTHING;