mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Init user database
This commit is contained in:
parent
73e3c6c64b
commit
629660bb79
2
auth/.gitignore
vendored
Normal file
2
auth/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# generated via sqlc
|
||||
db/
|
11
auth/go.mod
Normal file
11
auth/go.mod
Normal file
@ -0,0 +1,11 @@
|
||||
module github.com/zoriya/kyoo/keibi
|
||||
|
||||
go 1.22.5
|
||||
|
||||
require (
|
||||
github.com/golang-migrate/migrate/v4 v4.17.1 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
)
|
16
auth/go.sum
Normal file
16
auth/go.sum
Normal file
@ -0,0 +1,16 @@
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4=
|
||||
github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
0
auth/sql/migrations/000001_users.down.sql
Normal file
0
auth/sql/migrations/000001_users.down.sql
Normal file
15
auth/sql/migrations/000001_users.up.sql
Normal file
15
auth/sql/migrations/000001_users.up.sql
Normal file
@ -0,0 +1,15 @@
|
||||
begin;
|
||||
|
||||
create table users(
|
||||
id uuid primary key,
|
||||
username varchar(256) not null unique,
|
||||
email varchar(320) not null unique,
|
||||
password text,
|
||||
external_handle jsonb not null,
|
||||
claims jsonb not null,
|
||||
|
||||
created_date timestampz not null default now()::timestampz,
|
||||
last_seen timestampz not null default now()::timestampz
|
||||
);
|
||||
|
||||
commit;
|
44
auth/sql/queries/users.sql
Normal file
44
auth/sql/queries/users.sql
Normal file
@ -0,0 +1,44 @@
|
||||
-- name: GetAllUsers :many
|
||||
select
|
||||
*
|
||||
from
|
||||
users
|
||||
order by
|
||||
created_date
|
||||
limit $1;
|
||||
|
||||
-- name: GetUser :one
|
||||
select
|
||||
*
|
||||
from
|
||||
users
|
||||
where
|
||||
id = $1
|
||||
limit 1;
|
||||
|
||||
-- name: CreateUser :one
|
||||
insert into users(username, email, password, external_handle, claims)
|
||||
values ($1, $2, $3, $4, $5)
|
||||
returning
|
||||
*;
|
||||
|
||||
-- name: UpdateUser :one
|
||||
update
|
||||
users
|
||||
set
|
||||
username = $2,
|
||||
email = $3,
|
||||
password = $4,
|
||||
external_handle = $5,
|
||||
claims = $6
|
||||
where
|
||||
id = $1
|
||||
returning
|
||||
*;
|
||||
|
||||
-- name: DeleteUser :one
|
||||
delete from users
|
||||
where id = $1
|
||||
returning
|
||||
*;
|
||||
|
9
auth/sqlc.yaml
Normal file
9
auth/sqlc.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
version: "2"
|
||||
sql:
|
||||
- engine: "postgresql"
|
||||
queries: "sql/queries"
|
||||
schema: "sql/migrations"
|
||||
gen:
|
||||
go:
|
||||
package: "db"
|
||||
out: "db"
|
Loading…
x
Reference in New Issue
Block a user