mirror of
https://github.com/OHV-IT/collabrix.git
synced 2025-12-15 16:48:36 +01:00
- Complete chat application similar to Microsoft Teams - Code snippet library with syntax highlighting - Real-time messaging with WebSockets - File upload with Office integration - Department-based permissions - Dark/Light theme support - Production deployment with SSL/Reverse Proxy - Docker containerization - PostgreSQL database with SQLModel ORM
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Create direct_message table"""
|
|
import psycopg2
|
|
|
|
def main():
|
|
conn = psycopg2.connect('postgresql://postgres:your_password@192.168.0.19/OfficeDesk')
|
|
cur = conn.cursor()
|
|
|
|
print("Creating direct_message table...")
|
|
|
|
cur.execute('''
|
|
CREATE TABLE IF NOT EXISTS direct_message (
|
|
id SERIAL PRIMARY KEY,
|
|
content TEXT NOT NULL,
|
|
sender_id INTEGER NOT NULL REFERENCES "user"(id),
|
|
receiver_id INTEGER NOT NULL REFERENCES "user"(id),
|
|
snippet_id INTEGER REFERENCES snippet(id),
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
is_read BOOLEAN DEFAULT FALSE
|
|
)
|
|
''')
|
|
|
|
cur.execute('''
|
|
CREATE INDEX IF NOT EXISTS idx_dm_sender ON direct_message(sender_id)
|
|
''')
|
|
|
|
cur.execute('''
|
|
CREATE INDEX IF NOT EXISTS idx_dm_receiver ON direct_message(receiver_id)
|
|
''')
|
|
|
|
cur.execute('''
|
|
CREATE INDEX IF NOT EXISTS idx_dm_created ON direct_message(created_at DESC)
|
|
''')
|
|
|
|
conn.commit()
|
|
print("✅ direct_message table created successfully!")
|
|
|
|
cur.close()
|
|
conn.close()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|