working commit
This commit is contained in:
@@ -19,7 +19,7 @@ func (db *Database) InsertAccount(ctx context.Context, account *descr.Account) e
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) UpdateAccountByID(ctx context.Context, accountID int64, account *descr.Account) error {
|
||||
func (db *Database) UpdateAccountByID(ctx context.Context, accountID string, account *descr.Account) error {
|
||||
var err error
|
||||
|
||||
request := `UPDATE accounts SET username = $1, passhash = $2, disabled = $3, updated_at = $4 WHERE id = $6`
|
||||
@@ -52,7 +52,7 @@ func (db *Database) CompletedListAccounts(ctx context.Context) ([]descr.Account,
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetAccountByID(ctx context.Context, accountID int64) (bool, *descr.Account, error) {
|
||||
func (db *Database) GetAccountByID(ctx context.Context, accountID string) (bool, *descr.Account, error) {
|
||||
var err error
|
||||
var res *descr.Account
|
||||
var exists bool
|
||||
@@ -90,7 +90,7 @@ func (db *Database) GetAccountByUsername(ctx context.Context, username string) (
|
||||
return exists, res, err
|
||||
}
|
||||
|
||||
func (db *Database) DeleteAccountByID(ctx context.Context, accountID int64) error {
|
||||
func (db *Database) DeleteAccountByID(ctx context.Context, accountID string) error {
|
||||
var err error
|
||||
|
||||
request := `DELETE FROM accounts WHERE id = $1`
|
||||
|
||||
+4
-4
@@ -17,7 +17,7 @@ func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID int64) ([]descr.Grant, error) {
|
||||
func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID string) ([]descr.Grant, error) {
|
||||
var err error
|
||||
request := `SELECT * FROM grants WHERE account_id = $1`
|
||||
res := make([]descr.Grant, 0)
|
||||
@@ -39,7 +39,7 @@ func (db *Database) ListGrants(ctx context.Context) ([]descr.Grant, error) {
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrant(ctx context.Context, accountID int64, operation string) (bool, *descr.Grant, error) {
|
||||
func (db *Database) GetGrant(ctx context.Context, accountID, operation string) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND operation = $2 LIMIT 1`
|
||||
@@ -56,7 +56,7 @@ func (db *Database) GetGrant(ctx context.Context, accountID int64, operation str
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID int64, operation string) error {
|
||||
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID, operation string) error {
|
||||
var err error
|
||||
request := `DELETE FROM grants WHERE account_id = $1 AND operation = $2`
|
||||
_, err = db.db.Exec(request, grantID, operation)
|
||||
@@ -66,7 +66,7 @@ func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID int64, o
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID int64) error {
|
||||
func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID string) error {
|
||||
var err error
|
||||
request := `DELETE FROM grants WHERE account_id = $1`
|
||||
_, err = db.db.Exec(request, grantID)
|
||||
|
||||
@@ -58,7 +58,7 @@ const schema = `
|
||||
|
||||
--- DROP TABLE IF EXISTS accounts;
|
||||
CREATE TABLE IF NOT EXISTS accounts (
|
||||
id INT NOT NULL,
|
||||
id TEXT NOT NULL,
|
||||
username TEXT NOT NULL,
|
||||
passhash TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
@@ -72,7 +72,7 @@ const schema = `
|
||||
|
||||
--- DROP TABLE IF EXISTS grants;
|
||||
CREATE TABLE IF NOT EXISTS grants (
|
||||
id INT NOT NULL,
|
||||
id TEXT NOT NULL,
|
||||
account_id INT NOT NULL,
|
||||
operation TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
|
||||
Reference in New Issue
Block a user