| 
									
										
										
										
											2024-11-08 15:47:21 -05:00
										 |  |  | begin transaction;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-08 20:31:00 -05:00
										 |  |  | create table newsgroup (
 | 
					
						
							|  |  |  |     id          INTEGER PRIMARY KEY NOT NULL,
 | 
					
						
							| 
									
										
										
										
											2024-11-09 11:54:20 -05:00
										 |  |  |     created_on  DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
 | 
					
						
							| 
									
										
										
										
											2024-11-08 20:31:00 -05:00
										 |  |  |     name        TEXT NOT NULL,
 | 
					
						
							|  |  |  |     description TEXT NOT NULL
 | 
					
						
							|  |  |  | );
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-08 15:47:21 -05:00
										 |  |  | create table newsgroup_message (
 | 
					
						
							| 
									
										
										
										
											2024-11-08 20:31:00 -05:00
										 |  |  |     id           INTEGER PRIMARY KEY NOT NULL,
 | 
					
						
							| 
									
										
										
										
											2024-11-09 11:54:31 -05:00
										 |  |  |     created_on   DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
 | 
					
						
							| 
									
										
										
										
											2024-11-08 20:31:00 -05:00
										 |  |  |     newsgroup_id INTEGER NOT NULL,
 | 
					
						
							| 
									
										
										
										
											2024-11-09 10:34:50 -05:00
										 |  |  |     message_id   TEXT NOT NULL UNIQUE,
 | 
					
						
							| 
									
										
										
										
											2024-11-09 15:36:57 -05:00
										 |  |  |     parent_id    TEXT,
 | 
					
						
							| 
									
										
										
										
											2024-11-08 20:31:00 -05:00
										 |  |  |     sender       TEXT NOT NULL,
 | 
					
						
							|  |  |  |     subject      TEXT NOT NULL,
 | 
					
						
							|  |  |  |     content      TEXT NOT NULL,
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     FOREIGN KEY(newsgroup_id) REFERENCES newsgroup(id)
 | 
					
						
							| 
									
										
										
										
											2024-11-08 15:47:21 -05:00
										 |  |  | );
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 15:52:36 -05:00
										 |  |  | create index newsgroup_message_newsgroup_id_idx on newsgroup_message (
 | 
					
						
							|  |  |  |     newsgroup_id, id
 | 
					
						
							|  |  |  | );
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-25 17:16:34 -05:00
										 |  |  | create index newsgroup_message_newsgroup_date_idx on newsgroup_message (
 | 
					
						
							|  |  |  |     newsgroup_id, created_on
 | 
					
						
							|  |  |  | );
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-08 15:47:21 -05:00
										 |  |  | commit;
 |