Groo12 commited on
Commit
af4689d
·
1 Parent(s): 3e8222a

Add application file

Browse files
Files changed (1) hide show
  1. models.py +10 -0
models.py CHANGED
@@ -11,6 +11,16 @@ class Database:
11
  self.conn = psycopg2.connect(os.getenv("POSTGRES_URL"))
12
  self.cursor = self.conn.cursor()
13
  # Verify tables exist on startup
 
 
 
 
 
 
 
 
 
 
14
  self.cursor.execute("""
15
  SELECT EXISTS (
16
  SELECT FROM information_schema.tables
 
11
  self.conn = psycopg2.connect(os.getenv("POSTGRES_URL"))
12
  self.cursor = self.conn.cursor()
13
  # Verify tables exist on startup
14
+ self.cursor.execute("""
15
+ CREATE TABLE IF NOT EXISTS messages (
16
+ id SERIAL PRIMARY KEY,
17
+ sender VARCHAR(50),
18
+ body TEXT,
19
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
20
+ )
21
+ """)
22
+ self.conn.commit()
23
+
24
  self.cursor.execute("""
25
  SELECT EXISTS (
26
  SELECT FROM information_schema.tables