Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
951ce0a1
Commit
951ce0a1
authored
Jan 27, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API token -> API key rename
parent
db371d2a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
84 deletions
+90
-84
grafana
+1
-1
pkg/api/api.go
+6
-6
pkg/api/apikey.go
+18
-18
pkg/middleware/auth.go
+3
-3
pkg/middleware/middleware.go
+8
-8
pkg/models/apikey.go
+19
-20
pkg/services/sqlstore/apikey.go
+19
-21
pkg/services/sqlstore/migrations.go
+16
-7
No files found.
grafana
@
11b74baf
Subproject commit
d2f21bc93e96d9ac36b1925c0b0b137a7edc94d
2
Subproject commit
11b74baf7920bcd4e39b5e77bfb49e6b08752dc
2
pkg/api/api.go
View file @
951ce0a1
...
@@ -58,13 +58,13 @@ func Register(r *macaron.Macaron) {
...
@@ -58,13 +58,13 @@ func Register(r *macaron.Macaron) {
r
.
Delete
(
"/users/:id"
,
RemoveAccountUser
)
r
.
Delete
(
"/users/:id"
,
RemoveAccountUser
)
},
reqAccountAdmin
)
},
reqAccountAdmin
)
//
Token
//
auth api keys
r
.
Group
(
"/
token
s"
,
func
()
{
r
.
Group
(
"/
auth/key
s"
,
func
()
{
r
.
Combo
(
"/"
)
.
r
.
Combo
(
"/"
)
.
Get
(
Get
Token
s
)
.
Get
(
Get
ApiKey
s
)
.
Post
(
bind
(
m
.
Add
TokenCommand
{}),
AddToken
)
.
Post
(
bind
(
m
.
Add
ApiKeyCommand
{}),
AddApiKey
)
.
Put
(
bind
(
m
.
Update
TokenCommand
{}),
UpdateToken
)
Put
(
bind
(
m
.
Update
ApiKeyCommand
{}),
UpdateApiKey
)
r
.
Delete
(
"/:id"
,
Delete
Token
)
r
.
Delete
(
"/:id"
,
Delete
ApiKey
)
},
reqAccountAdmin
)
},
reqAccountAdmin
)
// Data sources
// Data sources
...
...
pkg/api/
token
.go
→
pkg/api/
apikey
.go
View file @
951ce0a1
...
@@ -7,65 +7,65 @@ import (
...
@@ -7,65 +7,65 @@ import (
"github.com/torkelo/grafana-pro/pkg/util"
"github.com/torkelo/grafana-pro/pkg/util"
)
)
func
Get
Token
s
(
c
*
middleware
.
Context
)
{
func
Get
ApiKey
s
(
c
*
middleware
.
Context
)
{
query
:=
m
.
Get
Token
sQuery
{
AccountId
:
c
.
AccountId
}
query
:=
m
.
Get
ApiKey
sQuery
{
AccountId
:
c
.
AccountId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to list
token
s"
,
err
)
c
.
JsonApiErr
(
500
,
"Failed to list
api key
s"
,
err
)
return
return
}
}
result
:=
make
([]
*
m
.
Token
DTO
,
len
(
query
.
Result
))
result
:=
make
([]
*
m
.
ApiKey
DTO
,
len
(
query
.
Result
))
for
i
,
t
:=
range
query
.
Result
{
for
i
,
t
:=
range
query
.
Result
{
result
[
i
]
=
&
m
.
Token
DTO
{
result
[
i
]
=
&
m
.
ApiKey
DTO
{
Id
:
t
.
Id
,
Id
:
t
.
Id
,
Name
:
t
.
Name
,
Name
:
t
.
Name
,
Role
:
t
.
Role
,
Role
:
t
.
Role
,
Token
:
t
.
Token
,
Key
:
t
.
Key
,
}
}
}
}
c
.
JSON
(
200
,
result
)
c
.
JSON
(
200
,
result
)
}
}
func
Delete
Token
(
c
*
middleware
.
Context
)
{
func
Delete
ApiKey
(
c
*
middleware
.
Context
)
{
id
:=
c
.
ParamsInt64
(
":id"
)
id
:=
c
.
ParamsInt64
(
":id"
)
cmd
:=
&
m
.
Delete
Token
Command
{
Id
:
id
,
AccountId
:
c
.
AccountId
}
cmd
:=
&
m
.
Delete
ApiKey
Command
{
Id
:
id
,
AccountId
:
c
.
AccountId
}
err
:=
bus
.
Dispatch
(
cmd
)
err
:=
bus
.
Dispatch
(
cmd
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to delete
token
"
,
err
)
c
.
JsonApiErr
(
500
,
"Failed to delete
API key
"
,
err
)
return
return
}
}
c
.
JsonOK
(
"
Token
deleted"
)
c
.
JsonOK
(
"
API key
deleted"
)
}
}
func
Add
Token
(
c
*
middleware
.
Context
,
cmd
m
.
AddToken
Command
)
{
func
Add
ApiKey
(
c
*
middleware
.
Context
,
cmd
m
.
AddApiKey
Command
)
{
if
!
cmd
.
Role
.
IsValid
()
{
if
!
cmd
.
Role
.
IsValid
()
{
c
.
JsonApiErr
(
400
,
"Invalid role specified"
,
nil
)
c
.
JsonApiErr
(
400
,
"Invalid role specified"
,
nil
)
return
return
}
}
cmd
.
AccountId
=
c
.
AccountId
cmd
.
AccountId
=
c
.
AccountId
cmd
.
Token
=
util
.
GetRandomString
(
64
)
cmd
.
Key
=
util
.
GetRandomString
(
64
)
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to add
token
"
,
err
)
c
.
JsonApiErr
(
500
,
"Failed to add
API key
"
,
err
)
return
return
}
}
result
:=
&
m
.
Token
DTO
{
result
:=
&
m
.
ApiKey
DTO
{
Id
:
cmd
.
Result
.
Id
,
Id
:
cmd
.
Result
.
Id
,
Name
:
cmd
.
Result
.
Name
,
Name
:
cmd
.
Result
.
Name
,
Role
:
cmd
.
Result
.
Role
,
Role
:
cmd
.
Result
.
Role
,
Token
:
cmd
.
Result
.
Token
,
Key
:
cmd
.
Result
.
Key
,
}
}
c
.
JSON
(
200
,
result
)
c
.
JSON
(
200
,
result
)
}
}
func
Update
Token
(
c
*
middleware
.
Context
,
cmd
m
.
UpdateToken
Command
)
{
func
Update
ApiKey
(
c
*
middleware
.
Context
,
cmd
m
.
UpdateApiKey
Command
)
{
if
!
cmd
.
Role
.
IsValid
()
{
if
!
cmd
.
Role
.
IsValid
()
{
c
.
JsonApiErr
(
400
,
"Invalid role specified"
,
nil
)
c
.
JsonApiErr
(
400
,
"Invalid role specified"
,
nil
)
return
return
...
@@ -75,9 +75,9 @@ func UpdateToken(c *middleware.Context, cmd m.UpdateTokenCommand) {
...
@@ -75,9 +75,9 @@ func UpdateToken(c *middleware.Context, cmd m.UpdateTokenCommand) {
err
:=
bus
.
Dispatch
(
&
cmd
)
err
:=
bus
.
Dispatch
(
&
cmd
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to update
token
"
,
err
)
c
.
JsonApiErr
(
500
,
"Failed to update
api key
"
,
err
)
return
return
}
}
c
.
JsonOK
(
"
Token
updated"
)
c
.
JsonOK
(
"
API key
updated"
)
}
}
pkg/middleware/auth.go
View file @
951ce0a1
...
@@ -31,12 +31,12 @@ func getRequestUserId(c *Context) int64 {
...
@@ -31,12 +31,12 @@ func getRequestUserId(c *Context) int64 {
return
0
return
0
}
}
func
getApi
Token
(
c
*
Context
)
string
{
func
getApi
Key
(
c
*
Context
)
string
{
header
:=
c
.
Req
.
Header
.
Get
(
"Authorization"
)
header
:=
c
.
Req
.
Header
.
Get
(
"Authorization"
)
parts
:=
strings
.
SplitN
(
header
,
" "
,
2
)
parts
:=
strings
.
SplitN
(
header
,
" "
,
2
)
if
len
(
parts
)
==
2
||
parts
[
0
]
==
"Bearer"
{
if
len
(
parts
)
==
2
||
parts
[
0
]
==
"Bearer"
{
token
:=
parts
[
1
]
key
:=
parts
[
1
]
return
token
return
key
}
}
return
""
return
""
...
...
pkg/middleware/middleware.go
View file @
951ce0a1
...
@@ -39,22 +39,22 @@ func GetContextHandler() macaron.Handler {
...
@@ -39,22 +39,22 @@ func GetContextHandler() macaron.Handler {
ctx
.
IsSignedIn
=
true
ctx
.
IsSignedIn
=
true
ctx
.
SignedInUser
=
query
.
Result
ctx
.
SignedInUser
=
query
.
Result
}
}
}
else
if
token
:=
getApiToken
(
ctx
);
token
!=
""
{
}
else
if
key
:=
getApiKey
(
ctx
);
key
!=
""
{
// Try API Key auth
// Try API Key auth
tokenQuery
:=
m
.
GetTokenByTokenQuery
{
Token
:
token
}
keyQuery
:=
m
.
GetApiKeyByKeyQuery
{
Key
:
key
}
if
err
:=
bus
.
Dispatch
(
&
token
Query
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
&
key
Query
);
err
!=
nil
{
ctx
.
JsonApiErr
(
401
,
"Invalid
token
"
,
err
)
ctx
.
JsonApiErr
(
401
,
"Invalid
API key
"
,
err
)
return
return
}
else
{
}
else
{
tokenInfo
:=
token
Query
.
Result
keyInfo
:=
key
Query
.
Result
ctx
.
IsSignedIn
=
true
ctx
.
IsSignedIn
=
true
ctx
.
SignedInUser
=
&
m
.
SignedInUser
{}
ctx
.
SignedInUser
=
&
m
.
SignedInUser
{}
// TODO: fix this
// TODO: fix this
ctx
.
AccountRole
=
token
Info
.
Role
ctx
.
AccountRole
=
key
Info
.
Role
ctx
.
ApiKeyId
=
token
Info
.
Id
ctx
.
ApiKeyId
=
key
Info
.
Id
ctx
.
AccountId
=
token
Info
.
AccountId
ctx
.
AccountId
=
key
Info
.
AccountId
}
}
}
}
...
...
pkg/models/
token
.go
→
pkg/models/
apikey
.go
View file @
951ce0a1
...
@@ -5,62 +5,61 @@ import (
...
@@ -5,62 +5,61 @@ import (
"time"
"time"
)
)
var
ErrInvalid
Token
=
errors
.
New
(
"Invalid token
"
)
var
ErrInvalid
ApiKey
=
errors
.
New
(
"Invalid API Key
"
)
type
Token
struct
{
type
ApiKey
struct
{
Id
int64
Id
int64
AccountId
int64
`xorm:"not null unique(uix_account_id_name)"`
AccountId
int64
Name
string
`xorm:"not null unique(uix_account_id_name)"`
Name
string
Token
string
`xorm:"UNIQUE NOT NULL"`
Key
string
Role
RoleType
`xorm:"not null"`
Role
RoleType
Created
time
.
Time
Created
time
.
Time
Updated
time
.
Time
Updated
time
.
Time
}
}
// ---------------------
// ---------------------
// COMMANDS
// COMMANDS
type
Add
Token
Command
struct
{
type
Add
ApiKey
Command
struct
{
Name
string
`json:"name" binding:"required"`
Name
string
`json:"name" binding:"required"`
Role
RoleType
`json:"role" binding:"required"`
Role
RoleType
`json:"role" binding:"required"`
AccountId
int64
`json:"-"`
AccountId
int64
`json:"-"`
Token
string
`json:"-"`
Key
string
`json:"-"`
Result
*
Token
`json:"-"`
Result
*
ApiKey
`json:"-"`
}
}
type
Update
Token
Command
struct
{
type
Update
ApiKey
Command
struct
{
Id
int64
`json:"id"`
Id
int64
`json:"id"`
Name
string
`json:"name"`
Name
string
`json:"name"`
Role
RoleType
`json:"role"`
Role
RoleType
`json:"role"`
AccountId
int64
`json:"-"`
AccountId
int64
`json:"-"`
Result
*
Token
`json:"-"`
}
}
type
Delete
Token
Command
struct
{
type
Delete
ApiKey
Command
struct
{
Id
int64
`json:"id"`
Id
int64
`json:"id"`
AccountId
int64
`json:"-"`
AccountId
int64
`json:"-"`
Result
*
Token
`json:"-"`
}
}
// ----------------------
// ----------------------
// QUERIES
// QUERIES
type
Get
Token
sQuery
struct
{
type
Get
ApiKey
sQuery
struct
{
AccountId
int64
AccountId
int64
Result
[]
*
Token
Result
[]
*
ApiKey
}
}
type
Get
TokenByToken
Query
struct
{
type
Get
ApiKeyByKey
Query
struct
{
Token
string
Key
string
Result
*
Token
Result
*
ApiKey
}
}
// ------------------------
// ------------------------
// DTO & Projections
// DTO & Projections
type
Token
DTO
struct
{
type
ApiKey
DTO
struct
{
Id
int64
`json:"id"`
Id
int64
`json:"id"`
Name
string
`json:"name"`
Name
string
`json:"name"`
Token
string
`json:"token
"`
Key
string
`json:"key
"`
Role
RoleType
`json:"role"`
Role
RoleType
`json:"role"`
}
}
pkg/services/sqlstore/
tokens
.go
→
pkg/services/sqlstore/
apikey
.go
View file @
951ce0a1
...
@@ -9,35 +9,35 @@ import (
...
@@ -9,35 +9,35 @@ import (
)
)
func
init
()
{
func
init
()
{
bus
.
AddHandler
(
"sql"
,
Get
Token
s
)
bus
.
AddHandler
(
"sql"
,
Get
ApiKey
s
)
bus
.
AddHandler
(
"sql"
,
Get
TokenByToken
)
bus
.
AddHandler
(
"sql"
,
Get
ApiKeyByKey
)
bus
.
AddHandler
(
"sql"
,
Update
Token
)
bus
.
AddHandler
(
"sql"
,
Update
ApiKey
)
bus
.
AddHandler
(
"sql"
,
Delete
Token
)
bus
.
AddHandler
(
"sql"
,
Delete
ApiKey
)
bus
.
AddHandler
(
"sql"
,
Add
Token
)
bus
.
AddHandler
(
"sql"
,
Add
ApiKey
)
}
}
func
Get
Tokens
(
query
*
m
.
GetToken
sQuery
)
error
{
func
Get
ApiKeys
(
query
*
m
.
GetApiKey
sQuery
)
error
{
sess
:=
x
.
Limit
(
100
,
0
)
.
Where
(
"account_id=?"
,
query
.
AccountId
)
.
Asc
(
"name"
)
sess
:=
x
.
Limit
(
100
,
0
)
.
Where
(
"account_id=?"
,
query
.
AccountId
)
.
Asc
(
"name"
)
query
.
Result
=
make
([]
*
m
.
Token
,
0
)
query
.
Result
=
make
([]
*
m
.
ApiKey
,
0
)
return
sess
.
Find
(
&
query
.
Result
)
return
sess
.
Find
(
&
query
.
Result
)
}
}
func
Delete
Token
(
cmd
*
m
.
DeleteToken
Command
)
error
{
func
Delete
ApiKey
(
cmd
*
m
.
DeleteApiKey
Command
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
var
rawSql
=
"DELETE FROM
token
WHERE id=? and account_id=?"
var
rawSql
=
"DELETE FROM
api_key
WHERE id=? and account_id=?"
_
,
err
:=
sess
.
Exec
(
rawSql
,
cmd
.
Id
,
cmd
.
AccountId
)
_
,
err
:=
sess
.
Exec
(
rawSql
,
cmd
.
Id
,
cmd
.
AccountId
)
return
err
return
err
})
})
}
}
func
Add
Token
(
cmd
*
m
.
AddToken
Command
)
error
{
func
Add
ApiKey
(
cmd
*
m
.
AddApiKey
Command
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
t
:=
m
.
Token
{
t
:=
m
.
ApiKey
{
AccountId
:
cmd
.
AccountId
,
AccountId
:
cmd
.
AccountId
,
Name
:
cmd
.
Name
,
Name
:
cmd
.
Name
,
Role
:
cmd
.
Role
,
Role
:
cmd
.
Role
,
Token
:
cmd
.
Token
,
Key
:
cmd
.
Key
,
Created
:
time
.
Now
(),
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
Updated
:
time
.
Now
(),
}
}
...
@@ -50,32 +50,30 @@ func AddToken(cmd *m.AddTokenCommand) error {
...
@@ -50,32 +50,30 @@ func AddToken(cmd *m.AddTokenCommand) error {
})
})
}
}
func
UpdateToken
(
cmd
*
m
.
UpdateTokenCommand
)
error
{
func
UpdateApiKey
(
cmd
*
m
.
UpdateApiKeyCommand
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
return
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
t
:=
m
.
Token
{
t
:=
m
.
ApiKey
{
Id
:
cmd
.
Id
,
Id
:
cmd
.
Id
,
AccountId
:
cmd
.
AccountId
,
AccountId
:
cmd
.
AccountId
,
Name
:
cmd
.
Name
,
Name
:
cmd
.
Name
,
Role
:
cmd
.
Role
,
Role
:
cmd
.
Role
,
Updated
:
time
.
Now
(),
Updated
:
time
.
Now
(),
}
}
_
,
err
:=
sess
.
Where
(
"id=? and account_id=?"
,
t
.
Id
,
t
.
AccountId
)
.
Update
(
&
t
)
_
,
err
:=
sess
.
Where
(
"id=? and account_id=?"
,
t
.
Id
,
t
.
AccountId
)
.
Update
(
&
t
)
return
err
return
err
})
})
}
}
func
Get
TokenByToken
(
query
*
m
.
GetTokenByToken
Query
)
error
{
func
Get
ApiKeyByKey
(
query
*
m
.
GetApiKeyByKey
Query
)
error
{
var
token
m
.
Token
var
apikey
m
.
ApiKey
has
,
err
:=
x
.
Where
(
"
token=?"
,
query
.
Token
)
.
Get
(
&
token
)
has
,
err
:=
x
.
Where
(
"
key=?"
,
query
.
Key
)
.
Get
(
&
apikey
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
else
if
has
==
false
{
}
else
if
has
==
false
{
return
m
.
ErrInvalid
Token
return
m
.
ErrInvalid
ApiKey
}
}
query
.
Result
=
&
token
query
.
Result
=
&
apikey
return
nil
return
nil
}
}
pkg/services/sqlstore/migrations.go
View file @
951ce0a1
...
@@ -2,13 +2,19 @@ package sqlstore
...
@@ -2,13 +2,19 @@ package sqlstore
import
.
"github.com/torkelo/grafana-pro/pkg/services/sqlstore/migrator"
import
.
"github.com/torkelo/grafana-pro/pkg/services/sqlstore/migrator"
// --- Migration Guide line ---
// 1. Never change a migration that is committed and pushed to master
// 2. Always add new migrations (to change or undo previous migrations)
// 3. Some migraitons are not yet written (rename column, table, drop table, index etc)
// 4
func
addMigrations
(
mg
*
Migrator
)
{
func
addMigrations
(
mg
*
Migrator
)
{
addMigrationLogMigrations
(
mg
)
addMigrationLogMigrations
(
mg
)
addUserMigrations
(
mg
)
addUserMigrations
(
mg
)
addAccountMigrations
(
mg
)
addAccountMigrations
(
mg
)
addDashboardMigration
(
mg
)
addDashboardMigration
(
mg
)
addDataSourceMigration
(
mg
)
addDataSourceMigration
(
mg
)
add
Token
Migrations
(
mg
)
add
ApiKey
Migrations
(
mg
)
}
}
func
addMigrationLogMigrations
(
mg
*
Migrator
)
{
func
addMigrationLogMigrations
(
mg
*
Migrator
)
{
...
@@ -131,19 +137,22 @@ func addDataSourceMigration(mg *Migrator) {
...
@@ -131,19 +137,22 @@ func addDataSourceMigration(mg *Migrator) {
Table
(
"data_source"
)
.
Columns
(
"account_id"
,
"name"
)
.
Unique
())
Table
(
"data_source"
)
.
Columns
(
"account_id"
,
"name"
)
.
Unique
())
}
}
func
add
Token
Migrations
(
mg
*
Migrator
)
{
func
add
ApiKey
Migrations
(
mg
*
Migrator
)
{
mg
.
AddMigration
(
"create
token
table"
,
new
(
AddTableMigration
)
.
mg
.
AddMigration
(
"create
api_key
table"
,
new
(
AddTableMigration
)
.
Name
(
"
token
"
)
.
WithColumns
(
Name
(
"
api_key
"
)
.
WithColumns
(
&
Column
{
Name
:
"id"
,
Type
:
DB_BigInt
,
IsPrimaryKey
:
true
,
IsAutoIncrement
:
true
},
&
Column
{
Name
:
"id"
,
Type
:
DB_BigInt
,
IsPrimaryKey
:
true
,
IsAutoIncrement
:
true
},
&
Column
{
Name
:
"account_id"
,
Type
:
DB_BigInt
,
Nullable
:
false
},
&
Column
{
Name
:
"account_id"
,
Type
:
DB_BigInt
,
Nullable
:
false
},
&
Column
{
Name
:
"name"
,
Type
:
DB_NVarchar
,
Length
:
255
,
Nullable
:
false
},
&
Column
{
Name
:
"name"
,
Type
:
DB_NVarchar
,
Length
:
255
,
Nullable
:
false
},
&
Column
{
Name
:
"
token"
,
Type
:
DB_NVarchar
,
Length
:
255
,
Nullable
:
false
},
&
Column
{
Name
:
"
key"
,
Type
:
DB_Varchar
,
Length
:
64
,
Nullable
:
false
},
&
Column
{
Name
:
"role"
,
Type
:
DB_NVarchar
,
Length
:
255
,
Nullable
:
false
},
&
Column
{
Name
:
"role"
,
Type
:
DB_NVarchar
,
Length
:
255
,
Nullable
:
false
},
&
Column
{
Name
:
"created"
,
Type
:
DB_DateTime
,
Nullable
:
false
},
&
Column
{
Name
:
"created"
,
Type
:
DB_DateTime
,
Nullable
:
false
},
&
Column
{
Name
:
"updated"
,
Type
:
DB_DateTime
,
Nullable
:
false
},
&
Column
{
Name
:
"updated"
,
Type
:
DB_DateTime
,
Nullable
:
false
},
))
))
//------- indexes ------------------
//------- indexes ------------------
mg
.
AddMigration
(
"add index token.account_id"
,
new
(
AddIndexMigration
)
.
mg
.
AddMigration
(
"add index api_key.account_id"
,
new
(
AddIndexMigration
)
.
Table
(
"token"
)
.
Columns
(
"account_id"
))
Table
(
"api_key"
)
.
Columns
(
"account_id"
))
mg
.
AddMigration
(
"add index api_key.key"
,
new
(
AddIndexMigration
)
.
Table
(
"api_key"
)
.
Columns
(
"key"
)
.
Unique
())
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment