mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: lifecycle trends migration (#10066)
Adding a single table to capture all lifecycle trends data. One field presents a challenge: `median_time_in_stage_days`. This value is calculated per `stage`, not per `flag_type`. As a result, we would need to duplicate the total median time across each flag type. This isn’t a major issue. An alternative would be to create a separate table solely for the median values, but that seems like overkill.
This commit is contained in:
		
							parent
							
								
									5be0b37cb1
								
							
						
					
					
						commit
						e474abb946
					
				
							
								
								
									
										23
									
								
								src/migrations/20250530103216-lifecycle-trends.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/migrations/20250530103216-lifecycle-trends.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| 'use strict'; | ||||
| 
 | ||||
| exports.up = function(db, cb) { | ||||
|     db.runSql( | ||||
|         ` | ||||
|             CREATE TABLE IF NOT EXISTS lifecycle_trends ( | ||||
|                 id TEXT NOT NULL, | ||||
|                 stage TEXT NOT NULL CHECK (stage IN ('initial','develop', 'production', 'cleanup', 'archived')), | ||||
|                 flag_type TEXT NOT NULL CHECK (flag_type IN ('experimental', 'release', 'permanent')), | ||||
|                 project VARCHAR(255) NOT NULL REFERENCES projects (id) ON DELETE CASCADE, | ||||
|                 flags_older_than_week INTEGER DEFAULT 0, | ||||
|                 new_flags_this_week INTEGER DEFAULT 0, | ||||
|                 created_at TIMESTAMP DEFAULT now(), | ||||
|                 PRIMARY KEY (id, stage, flag_type, project) | ||||
|                 ); | ||||
|         `,
 | ||||
|         cb, | ||||
|     ); | ||||
| }; | ||||
| 
 | ||||
| exports.down = function(db, cb) { | ||||
|     db.runSql('DROP TABLE IF EXISTS lifecycle_trends;', cb); | ||||
| }; | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user