Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10455835
v4.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
v4.go
View Options
package
migrations
import
(
"context"
"database/sql"
wf_db
"github.com/writeas/writefreely/db"
)
func
oauth
(
db
*
datastore
)
error
{
dialect
:=
wf_db
.
DialectMySQL
if
db
.
driverName
==
driverSQLite
{
dialect
=
wf_db
.
DialectSQLite
}
return
wf_db
.
RunTransactionWithOptions
(
context
.
Background
(),
db
.
DB
,
&
sql
.
TxOptions
{},
func
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
)
error
{
createTableUsersOauth
,
err
:=
dialect
.
Table
(
"oauth_users"
).
SetIfNotExists
(
true
).
Column
(
dialect
.
Column
(
"user_id"
,
wf_db
.
ColumnTypeInteger
,
wf_db
.
UnsetSize
)).
Column
(
dialect
.
Column
(
"remote_user_id"
,
wf_db
.
ColumnTypeInteger
,
wf_db
.
UnsetSize
)).
UniqueConstraint
(
"user_id"
).
UniqueConstraint
(
"remote_user_id"
).
ToSQL
()
if
err
!=
nil
{
return
err
}
createTableOauthClientState
,
err
:=
dialect
.
Table
(
"oauth_client_states"
).
SetIfNotExists
(
true
).
Column
(
dialect
.
Column
(
"state"
,
wf_db
.
ColumnTypeVarChar
,
wf_db
.
OptionalInt
{
Set
:
true
,
Value
:
255
})).
Column
(
dialect
.
Column
(
"used"
,
wf_db
.
ColumnTypeBool
,
wf_db
.
UnsetSize
)).
Column
(
dialect
.
Column
(
"created_at"
,
wf_db
.
ColumnTypeDateTime
,
wf_db
.
UnsetSize
).
SetDefault
(
"NOW()"
)).
UniqueConstraint
(
"state"
).
ToSQL
()
if
err
!=
nil
{
return
err
}
for
_
,
table
:=
range
[]
string
{
createTableUsersOauth
,
createTableOauthClientState
}
{
if
_
,
err
:=
tx
.
ExecContext
(
ctx
,
table
);
err
!=
nil
{
return
err
}
}
return
nil
})
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 1, 1:04 AM (20 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3146017
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment