Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Portal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fachschaft
Portal
Commits
dd04da50
Verified
Commit
dd04da50
authored
10 months ago
by
Jakob Moser
Browse files
Options
Downloads
Patches
Plain Diff
Add Alembic migrations
parent
a15ed101
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Add basic User auth endpoints (non functional)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
alembic/versions/d3889051d9e7_add_users_and_keys.py
+54
-0
54 additions, 0 deletions
alembic/versions/d3889051d9e7_add_users_and_keys.py
portal/model/__init__.py
+1
-0
1 addition, 0 deletions
portal/model/__init__.py
with
55 additions
and
0 deletions
alembic/versions/d3889051d9e7_add_users_and_keys.py
0 → 100644
+
54
−
0
View file @
dd04da50
"""
Add users and keys
Revision ID: d3889051d9e7
Revises: 2a60cb3fb390
Create Date: 2024-06-04 16:07:36.652116
"""
from
typing
import
Sequence
,
Union
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
:
str
=
"
d3889051d9e7
"
down_revision
:
Union
[
str
,
None
]
=
"
2a60cb3fb390
"
branch_labels
:
Union
[
str
,
Sequence
[
str
],
None
]
=
None
depends_on
:
Union
[
str
,
Sequence
[
str
],
None
]
=
None
from
portal.model
import
Uuid
,
UtcDateTime
def
upgrade
()
->
None
:
op
.
create_table
(
"
user
"
,
sa
.
Column
(
"
name
"
,
sa
.
String
(),
nullable
=
False
),
sa
.
Column
(
"
uuid
"
,
Uuid
(),
nullable
=
False
),
sa
.
PrimaryKeyConstraint
(
"
uuid
"
),
)
op
.
create_index
(
op
.
f
(
"
ix_user_name
"
),
"
user
"
,
[
"
name
"
],
unique
=
True
)
op
.
create_table
(
"
key
"
,
sa
.
Column
(
"
secret_hash
"
,
sa
.
String
(
length
=
256
),
nullable
=
False
),
sa
.
Column
(
"
created_at
"
,
UtcDateTime
(),
nullable
=
False
),
sa
.
Column
(
"
expires_at
"
,
UtcDateTime
(),
nullable
=
False
),
sa
.
Column
(
"
last_used_at
"
,
UtcDateTime
(),
nullable
=
True
),
sa
.
Column
(
"
user_uuid
"
,
Uuid
(),
nullable
=
False
),
sa
.
Column
(
"
uuid
"
,
Uuid
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
(
[
"
user_uuid
"
],
[
"
user.uuid
"
],
),
sa
.
PrimaryKeyConstraint
(
"
uuid
"
),
)
op
.
create_index
(
op
.
f
(
"
ix_key_secret_hash
"
),
"
key
"
,
[
"
secret_hash
"
],
unique
=
True
)
def
downgrade
()
->
None
:
op
.
drop_index
(
op
.
f
(
"
ix_key_secret_hash
"
),
table_name
=
"
key
"
)
op
.
drop_table
(
"
key
"
)
op
.
drop_index
(
op
.
f
(
"
ix_user_name
"
),
table_name
=
"
user
"
)
op
.
drop_table
(
"
user
"
)
This diff is collapsed.
Click to expand it.
portal/model/__init__.py
+
1
−
0
View file @
dd04da50
...
...
@@ -5,3 +5,4 @@ from .Retrievable import Retrievable
from
.User
import
User
from
.Uuid
import
Uuid
from
.Key
import
Key
from
.UtcDateTime
import
UtcDateTime
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment