Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Merge requests
!128
Add timestamps to workflow and capability requests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add timestamps to workflow and capability requests
add-created-updated-timestamps
into
main
Overview
1
Commits
1
Pipelines
1
Changes
3
Merged
Daniel Lyons
requested to merge
add-created-updated-timestamps
into
main
4 years ago
Overview
1
Commits
1
Pipelines
1
Changes
3
Expand
Add columns to tables workflow_requests and capability_requests
Make the updated_at column auto-update in the database for both
Use in the
repr
method for Python for human-friendliness
Manually verified that the timezone manipulations were correct
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
b592059a
1 commit,
4 years ago
3 files
+
147
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
schema/versions/72cee10f1f0d_add_created_updated_timestamps_to_.py
0 → 100644
+
89
−
0
Options
"""
add created/updated timestamps to capability and workflow requests
Revision ID: 72cee10f1f0d
Revises: 50ff97fe0c2a
Create Date: 2021-03-10 10:30:01.160958
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
"
72cee10f1f0d
"
down_revision
=
"
50ff97fe0c2a
"
branch_labels
=
None
depends_on
=
None
def
upgrade
():
op
.
add_column
(
"
capability_requests
"
,
sa
.
Column
(
"
created_at
"
,
sa
.
DateTime
(
timezone
=
True
),
server_default
=
sa
.
func
.
now
(),
nullable
=
False
,
),
)
op
.
add_column
(
"
workflow_requests
"
,
sa
.
Column
(
"
created_at
"
,
sa
.
DateTime
(
timezone
=
True
),
server_default
=
sa
.
func
.
now
(),
nullable
=
False
,
),
)
op
.
add_column
(
"
capability_requests
"
,
sa
.
Column
(
"
updated_at
"
,
sa
.
DateTime
(
timezone
=
True
),
server_default
=
sa
.
func
.
now
(),
nullable
=
False
,
),
)
op
.
add_column
(
"
workflow_requests
"
,
sa
.
Column
(
"
updated_at
"
,
sa
.
DateTime
(
timezone
=
True
),
server_default
=
sa
.
func
.
now
(),
nullable
=
False
,
),
)
op
.
execute
(
"""
create or replace function update_updated_at_timestamp() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
NEW.updated_at := current_timestamp;
RETURN NEW;
END;
$$;
"""
)
op
.
execute
(
"""
create trigger capability_request_updated
before update on capability_requests
for each row execute function update_updated_at_timestamp();
"""
)
op
.
execute
(
"""
create trigger workflow_request_updated
before update on workflow_requests
for each row execute function update_updated_at_timestamp();
"""
)
def
downgrade
():
op
.
drop_column
(
"
capability_requests
"
,
"
created_at
"
)
op
.
drop_column
(
"
workflow_requests
"
,
"
created_at
"
)
op
.
drop_column
(
"
capability_requests
"
,
"
updated_at
"
)
op
.
drop_column
(
"
workflow_requests
"
,
"
updated_at
"
)
op
.
execute
(
"
drop trigger workflow_request_updated on workflow_requests
"
)
op
.
execute
(
"
drop trigger capability_request_updated on capability_requests
"
)
op
.
execute
(
"
drop function update_updated_at_timestamp
"
)
Loading