Migrate to Xorm (#474)

close #234

* Migrate store
* Migrate tests
* Rewrite migrations
* Init fresh DB in on step
* Rm old stuff (meddler, sql files, dead code, ...)
This commit is contained in:
6543
2021-11-13 20:18:06 +01:00
committed by GitHub
parent aca5fddcf3
commit ca8e215cfa
582 changed files with 81745 additions and 17600 deletions

View File

@@ -1,3 +1,4 @@
// Copyright 2021 Woodpecker Authors
// Copyright 2018 Drone.IO Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,47 +32,52 @@ type User struct {
// the id for this user.
//
// required: true
ID int64 `json:"id" meddler:"user_id,pk"`
ID int64 `json:"id" xorm:"pk autoincr 'user_id'"`
// Login is the username for this user.
//
// required: true
Login string `json:"login" meddler:"user_login"`
Login string `json:"login" xorm:"UNIQUE 'user_login'"`
// Token is the oauth2 token.
Token string `json:"-" meddler:"user_token"`
Token string `json:"-" xorm:"TEXT 'user_token'"`
// Secret is the oauth2 token secret.
Secret string `json:"-" meddler:"user_secret"`
Secret string `json:"-" xorm:"TEXT 'user_secret'"`
// Expiry is the token and secret expiration timestamp.
Expiry int64 `json:"-" meddler:"user_expiry"`
Expiry int64 `json:"-" xorm:"user_expiry"`
// Email is the email address for this user.
//
// required: true
Email string `json:"email" meddler:"user_email"`
Email string `json:"email" xorm:" varchar(500) 'user_email'"`
// the avatar url for this user.
Avatar string `json:"avatar_url" meddler:"user_avatar"`
Avatar string `json:"avatar_url" xorm:" varchar(500) 'user_avatar'"`
// Activate indicates the user is active in the system.
Active bool `json:"active" meddler:"user_active"`
Active bool `json:"active" xorm:"user_active"`
// Synced is the timestamp when the user was synced with the remote system.
Synced int64 `json:"synced" meddler:"user_synced"`
Synced int64 `json:"synced" xorm:"user_synced"`
// Admin indicates the user is a system administrator.
//
// NOTE: This is sourced from the WOODPECKER_ADMINS environment variable and is no
// longer persisted in the database.
Admin bool `json:"admin,omitempty" meddler:"-"`
Admin bool `json:"admin,omitempty" xorm:"-"`
// Hash is a unique token used to sign tokens.
Hash string `json:"-" meddler:"user_hash"`
Hash string `json:"-" xorm:"UNIQUE varchar(500) 'user_hash'"`
// DEPRECATED Admin indicates the user is a system administrator.
XAdmin bool `json:"-" meddler:"user_admin"`
XAdmin bool `json:"-" xorm:"user_admin"`
}
// TableName return database table name for xorm
func (User) TableName() string {
return "users"
}
// Validate validates the required fields and formats.