Sync DB with DB_LivingAI
This commit is contained in:
parent
b0e51dd6da
commit
913e60f25d
|
|
@ -380,6 +380,7 @@ CREATE TABLE sold_information (
|
|||
sale_date TIMESTAMPTZ,
|
||||
notes TEXT,
|
||||
attachment_urls TEXT[],
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
|
@ -429,13 +430,29 @@ CREATE TABLE reviews (
|
|||
listing_rating INT CHECK (listing_rating >= 1 AND listing_rating <= 5),
|
||||
seller_rating INT CHECK (seller_rating >= 1 AND seller_rating <= 5),
|
||||
comment TEXT,
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
UNIQUE(listing_id, reviewer_id)
|
||||
);
|
||||
CREATE TRIGGER trg_reviews_updated_at BEFORE UPDATE ON reviews FOR EACH ROW EXECUTE FUNCTION set_updated_at();
|
||||
|
||||
-- 10. CHAT & COMMUNICATIONS
|
||||
-- 11. NOTIFICATIONS
|
||||
-- ======================================================
|
||||
CREATE TYPE notification_type_enum AS ENUM ('listing_expired', 'listing_enquiry', 'system_alert', 'other');
|
||||
|
||||
CREATE TABLE notifications (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
type notification_type_enum NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
data JSONB, -- Related entity IDs etc.
|
||||
is_read BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
CREATE INDEX idx_notifications_user_unread ON notifications(user_id) WHERE is_read = FALSE;
|
||||
|
||||
-- 12. CHAT & COMMUNICATIONS
|
||||
-- ======================================================
|
||||
CREATE TABLE conversations (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
|
|
@ -465,6 +482,7 @@ CREATE TABLE messages (
|
|||
-- Embedded Media
|
||||
message_media TEXT,
|
||||
media_type media_type_enum,
|
||||
media_metadata JSONB,
|
||||
|
||||
is_read BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
read_at TIMESTAMPTZ,
|
||||
|
|
|
|||
Loading…
Reference in New Issue