2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								package migrations
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 04:37:11 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func addAppSettingsMigration(mg *Migrator) {
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-25 21:55:31 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									pluginSettingTable := Table{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Name: "plugin_setting",
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Columns: []*Column{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "org_id", Type: DB_BigInt, Nullable: true},
							 | 
						
					
						
							
								
									
										
										
										
											2017-03-28 20:34:53 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											{Name: "plugin_id", Type: DB_NVarchar, Length: 190, Nullable: false},
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "enabled", Type: DB_Bool, Nullable: false},
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-22 06:09:27 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "pinned", Type: DB_Bool, Nullable: false},
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "json_data", Type: DB_Text, Nullable: true},
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-23 06:17:22 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "secure_json_data", Type: DB_Text, Nullable: true},
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "created", Type: DB_DateTime, Nullable: false},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "updated", Type: DB_DateTime, Nullable: false},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Indices: []*Index{
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-25 21:55:31 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Cols: []string{"org_id", "plugin_id"}, Type: UniqueIndex},
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-22 18:37:44 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-25 21:55:31 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									mg.AddMigration("create plugin_setting table", NewAddTableMigration(pluginSettingTable))
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									//-------  indexes ------------------
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-25 21:55:31 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									addTableIndicesMigrations(mg, "v1", pluginSettingTable)
							 | 
						
					
						
							
								
									
										
										
										
											2016-07-08 00:11:03 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// add column to store installed version
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									mg.AddMigration("Add column plugin_version to plugin_settings", NewAddColumnMigration(pluginSettingTable, &Column{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Name: "plugin_version", Type: DB_NVarchar, Nullable: true, Length: 50,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-03-28 20:34:53 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									mg.AddMigration("Update plugin_setting table charset", NewTableCharsetMigration("plugin_setting", []*Column{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										{Name: "plugin_id", Type: DB_NVarchar, Length: 190, Nullable: false},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										{Name: "json_data", Type: DB_Text, Nullable: true},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										{Name: "secure_json_data", Type: DB_Text, Nullable: true},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										{Name: "plugin_version", Type: DB_NVarchar, Nullable: true, Length: 50},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}))
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |