2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								package migrations
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-30 01:24:37 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import (
							 | 
						
					
						
							
								
									
										
										
										
											2023-05-25 21:38:30 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"github.com/grafana/grafana/pkg/services/featuremgmt"
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-11 21:02:53 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"github.com/grafana/grafana/pkg/services/sqlstore/migrations/accesscontrol"
							 | 
						
					
						
							
								
									
										
										
										
											2023-05-25 21:38:30 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"github.com/grafana/grafana/pkg/services/sqlstore/migrations/oauthserver"
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-30 01:24:37 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"github.com/grafana/grafana/pkg/services/sqlstore/migrations/ualert"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// --- Migration Guide line ---
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-06 22:29:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// 1. Never change a migration that is committed and pushed to main
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// 2. Always add new migrations (to change or undo previous migrations)
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-03 19:10:22 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// 3. Some migrations are not yet written (rename column, table, drop table, index etc)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-04 07:10:59 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// 4. Putting migrations behind feature flags is no longer recommended as broken
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								//    migrations may not be caught by integration tests unless feature flags are
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								//    specifically added
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-25 21:11:22 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								type OSSMigrations struct {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func ProvideOSSMigrations() *OSSMigrations {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									return &OSSMigrations{}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func (*OSSMigrations) AddMigration(mg *Migrator) {
							 | 
						
					
						
							
								
									
										
										
										
											2023-05-23 02:31:07 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									mg.AddCreateMigration()
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									addUserMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-16 23:59:11 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addTempUserMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									addStarMigrations(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									addOrgMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-30 01:24:37 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addDashboardMigration(mg) // Do NOT add more migrations to this function.
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									addDataSourceMigration(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									addApiKeyMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-21 20:53:16 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addDashboardSnapshotMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-20 20:51:27 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addQuotaMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-11 04:37:11 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addAppSettingsMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-23 15:33:46 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addSessionMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-24 18:25:49 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addPlaylistMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-04 17:29:46 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addPreferencesMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-13 16:33:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addAlertMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-01 16:07:00 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addAnnotationMig(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2017-03-31 00:03:50 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addTestDataMigrations(mg)
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												History and Version Control for Dashboard Updates
A simple version control system for dashboards. Closes #1504.
Goals
1. To create a new dashboard version every time a dashboard is saved.
2. To allow users to view all versions of a given dashboard.
3. To allow users to rollback to a previous version of a dashboard.
4. To allow users to compare two versions of a dashboard.
Usage
Navigate to a dashboard, and click the settings cog. From there, click
the "Changelog" button to be brought to the Changelog view. In this
view, a table containing each version of a dashboard can be seen. Each
entry in the table represents a dashboard version. A selectable
checkbox, the version number, date created, name of the user who created
that version, and commit message is shown in the table, along with a
button that allows a user to restore to a previous version of that
dashboard. If a user wants to restore to a previous version of their
dashboard, they can do so by clicking the previously mentioned button.
If a user wants to compare two different versions of a dashboard, they
can do so by clicking the checkbox of two different dashboard versions,
then clicking the "Compare versions" button located below the dashboard.
From there, the user is brought to a view showing a summary of the
dashboard differences. Each summarized change contains a link that can
be clicked to take the user a JSON diff highlighting the changes line by
line.
Overview of Changes
Backend Changes
- A `dashboard_version` table was created to store each dashboard
  version, along with a dashboard version model and structs to represent
  the queries and commands necessary for the dashboard version API
  methods.
- API endpoints were created to support working with dashboard
  versions.
- Methods were added to create, update, read, and destroy dashboard
  versions in the database.
  - Logic was added to compute the diff between two versions, and
  display it to the user.
  - The dashboard migration logic was updated to save a "Version
  1" of each existing dashboard in the database.
Frontend Changes
- New views
- Methods to pull JSON and HTML from endpoints
New API Endpoints
Each endpoint requires the authorization header to be sent in
the format,
```
Authorization: Bearer <jwt>
```
where `<jwt>` is a JSON web token obtained from the Grafana
admin panel.
`GET "/api/dashboards/db/:dashboardId/versions?orderBy=<string>&limit=<int>&start=<int>"`
Get all dashboard versions for the given dashboard ID. Accepts
three URL parameters:
- `orderBy` String to order the results by. Possible values
  are `version`, `created`, `created_by`, `message`. Default
  is `versions`. Ordering is always in descending order.
- `limit` Maximum number of results to return
- `start` Position in results to start from
`GET "/api/dashboards/db/:dashboardId/versions/:id"`
Get an individual dashboard version by ID, for the given
dashboard ID.
`POST "/api/dashboards/db/:dashboardId/restore"`
Restore to the given dashboard version. Post body is of
content-type `application/json`, and must contain.
```json
{
  "dashboardId": <int>,
  "version": <int>
}
```
`GET "/api/dashboards/db/:dashboardId/compare/:versionA...:versionB"`
Compare two dashboard versions by ID for the given
dashboard ID, returning a JSON delta formatted
representation of the diff. The URL format follows
what GitHub does. For example, visiting
[/api/dashboards/db/18/compare/22...33](http://ec2-54-80-139-44.compute-1.amazonaws.com:3000/api/dashboards/db/18/compare/22...33)
will return the diff between versions 22 and 33 for
the dashboard ID 18.
Dependencies Added
- The Go package [gojsondiff](https://github.com/yudai/gojsondiff)
  was added and vendored.
											
										 
										
											2017-05-25 07:14:39 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addDashboardVersionMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-08 23:25:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addTeamMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-07-18 21:14:58 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addDashboardACLMigrations(mg) // Do NOT add more migrations to this function.
							 | 
						
					
						
							
								
									
										
										
										
											2017-10-07 16:31:39 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addTagMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-26 17:41:41 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addLoginAttemptMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-09 06:13:58 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addUserAuthMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2018-12-13 16:52:13 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addServerlockMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-15 22:15:17 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addUserAuthTokenMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-15 06:13:46 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addCacheMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-14 18:48:48 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addShortURLMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-13 02:39:48 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ualert.AddTablesMigrations(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ualert.AddDashAlertMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-24 12:11:01 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addLibraryElementsMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-24 01:43:53 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-12 21:04:09 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ualert.RerunDashAlertMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-01 20:39:57 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addSecretsMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-31 23:05:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addKVStoreMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-04 23:33:55 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ualert.AddDashboardUIDPanelIDMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-11 21:02:53 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-29 00:55:09 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addQueryHistoryMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-01 21:57:26 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-04-19 23:34:19 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddDisabledMigrator(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-26 19:21:02 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddTeamMembershipMigrations(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddDashboardPermissionsMigrator(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddAlertingPermissionsMigrator(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-24 00:03:04 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addQueryHistoryStarMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-22 15:47:42 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-07-25 22:19:07 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addCorrelationsMigrations(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-27 16:29:39 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addEntityEventsTableMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-04 07:08:40 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									addPublicDashboardMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-13 23:49:04 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ualert.CreateDefaultFoldersForAlertingMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-17 01:26:40 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addDbFileStorageMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-05-23 22:50:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-09 01:33:32 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddManagedPermissionsMigration(mg, accesscontrol.ManagedPermissionsMigrationID)
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-01 21:29:37 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddManagedFolderAlertActionsMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-02 20:14:48 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddActionNameMigrator(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-15 03:32:52 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addPlaylistUIDMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 22:52:46 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ualert.UpdateRuleGroupIndexMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-07-15 00:01:21 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddManagedFolderAlertActionsRepeatMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-21 01:31:08 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddAdminOnlyMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-12 21:18:07 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddSeedAssignmentMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-03 16:57:20 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									accesscontrol.AddManagedFolderAlertActionsRepeatFixedMigration(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-26 22:15:14 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-10 23:34:13 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									AddExternalAlertmanagerToDatasourceMigration(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-30 18:17:40 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addFolderMigrations(mg)
							 | 
						
					
						
							
								
									
										
										
										
											2023-05-25 21:38:30 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if mg.Cfg != nil && mg.Cfg.IsFeatureToggleEnabled != nil {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagExternalServiceAuth) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											oauthserver.AddMigration(mg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								func addStarMigrations(mg *Migrator) {
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-25 01:32:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									starV1 := Table{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Name: "star",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Columns: []*Column{
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-07 23:23:22 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "user_id", Type: DB_BigInt, Nullable: false},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											{Name: "dashboard_id", Type: DB_BigInt, Nullable: false},
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-25 01:32:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Indices: []*Index{
							 | 
						
					
						
							
								
									
										
										
										
											2015-03-07 23:23:22 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											{Cols: []string{"user_id", "dashboard_id"}, Type: UniqueIndex},
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-25 01:32:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-25 01:32:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									mg.AddMigration("create star table", NewAddTableMigration(starV1))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									mg.AddMigration("add unique index star.user_id_dashboard_id", NewAddIndexMigration(starV1, starV1.Indices[0]))
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-24 18:46:34 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |