mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: observable events db migration (#5749)
https://linear.app/unleash/issue/2-1773/db-create-migration-for-a-new-observable-events-table Adds a new DB migration to create a new `observable_events` table. Even though we are thinking long term with the `source` columns, the short term purpose of this table will be to store incoming webhook calls.
This commit is contained in:
		
							parent
							
								
									fef6935d3a
								
							
						
					
					
						commit
						9c4a044543
					
				
							
								
								
									
										32
									
								
								src/migrations/20240102205517-observable-events.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/migrations/20240102205517-observable-events.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | exports.up = function (db, cb) { | ||||||
|  |     db.runSql( | ||||||
|  |         ` | ||||||
|  |         CREATE TABLE IF NOT EXISTS observable_events | ||||||
|  |             ( | ||||||
|  |                 id SERIAL PRIMARY KEY NOT NULL, | ||||||
|  |                 payload JSONB NOT NULL DEFAULT '{}'::jsonb, | ||||||
|  |                 created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), | ||||||
|  |                 source TEXT NOT NULL, | ||||||
|  |                 source_id INTEGER NOT NULL, | ||||||
|  |                 created_by_incoming_webhook_token_id INTEGER, | ||||||
|  |                 announced BOOLEAN DEFAULT false NOT NULL | ||||||
|  |             ); | ||||||
|  |         CREATE INDEX observable_events_source_and_source_id_idx ON observable_events(source, source_id); | ||||||
|  |         CREATE INDEX observable_events_created_by_incoming_webhook_token_id_idx ON observable_events(created_by_incoming_webhook_token_id); | ||||||
|  |         CREATE INDEX observable_events_unannounced_idx ON observable_events(announced) WHERE announced = false; | ||||||
|  |         `,
 | ||||||
|  |         cb, | ||||||
|  |     ); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | exports.down = function (db, cb) { | ||||||
|  |     db.runSql( | ||||||
|  |         ` | ||||||
|  |         DROP INDEX IF EXISTS observable_events_source_and_source_id_idx; | ||||||
|  |         DROP INDEX IF EXISTS observable_events_created_by_incoming_webhook_token_id_idx; | ||||||
|  |         DROP INDEX IF EXISTS observable_events_unannounced_idx; | ||||||
|  |         DROP TABLE IF EXISTS observable_events; | ||||||
|  |         `,
 | ||||||
|  |         cb, | ||||||
|  |     ); | ||||||
|  | }; | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user