Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
warehouse
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
Container 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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian
warehouse
Commits
dd7457a9
Commit
dd7457a9
authored
Mar 12, 2023
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Add photo creation date
parent
09a28a8e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
warehouse/migrations/versions/aabfcc081e98_add_photo_creation_date.py
+42
-0
42 additions, 0 deletions
...grations/versions/aabfcc081e98_add_photo_creation_date.py
warehouse/models.py
+2
-0
2 additions, 0 deletions
warehouse/models.py
with
44 additions
and
0 deletions
warehouse/migrations/versions/aabfcc081e98_add_photo_creation_date.py
0 → 100644
+
42
−
0
View file @
dd7457a9
"""
Add photo creation date
Revision ID: aabfcc081e98
Revises: 549a81db4351
Create Date: 2023-03-11 23:10:39.519330
"""
from
alembic
import
op
import
sqlalchemy
as
sa
from
flask
import
current_app
import
os
import
datetime
# revision identifiers, used by Alembic.
revision
=
'
aabfcc081e98
'
down_revision
=
'
549a81db4351
'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
with
op
.
batch_alter_table
(
'
photo
'
,
schema
=
None
)
as
batch_op
:
batch_op
.
add_column
(
sa
.
Column
(
'
created
'
,
sa
.
DateTime
(),
nullable
=
True
))
table
=
sa
.
table
(
'
photo
'
,
sa
.
column
(
'
id
'
,
sa
.
Integer
),
sa
.
column
(
'
path
'
,
sa
.
String
(
128
)),
sa
.
column
(
'
created
'
,
sa
.
DateTime
),
)
conn
=
op
.
get_bind
()
results
=
conn
.
execute
(
sa
.
select
(
table
.
c
.
id
,
table
.
c
.
path
)).
fetchall
()
for
photo_id
,
path
in
results
:
path
=
os
.
path
.
join
(
current_app
.
config
[
'
UPLOAD_FOLDER
'
],
path
)
created
=
datetime
.
datetime
.
utcfromtimestamp
(
os
.
path
.
getctime
(
path
))
op
.
execute
(
sa
.
update
(
table
).
where
(
table
.
c
.
id
==
photo_id
).
values
(
created
=
created
))
with
op
.
batch_alter_table
(
'
photo
'
,
schema
=
None
)
as
batch_op
:
batch_op
.
alter_column
(
'
created
'
,
existing_type
=
sa
.
DateTime
(),
nullable
=
False
)
def
downgrade
():
with
op
.
batch_alter_table
(
'
photo
'
,
schema
=
None
)
as
batch_op
:
batch_op
.
drop_column
(
'
created
'
)
This diff is collapsed.
Click to expand it.
warehouse/models.py
+
2
−
0
View file @
dd7457a9
import
secrets
import
secrets
import
os
import
os
import
io
import
io
import
datetime
from
flask
import
current_app
,
send_file
,
Markup
from
flask
import
current_app
,
send_file
,
Markup
from
flask_sqlalchemy
import
SQLAlchemy
from
flask_sqlalchemy
import
SQLAlchemy
...
@@ -13,6 +14,7 @@ class Photo(db.Model):
...
@@ -13,6 +14,7 @@ class Photo(db.Model):
id
=
db
.
Column
(
db
.
Integer
(),
primary_key
=
True
,
autoincrement
=
True
)
id
=
db
.
Column
(
db
.
Integer
(),
primary_key
=
True
,
autoincrement
=
True
)
mimetype
=
db
.
Column
(
db
.
String
(
128
),
nullable
=
False
)
mimetype
=
db
.
Column
(
db
.
String
(
128
),
nullable
=
False
)
path
=
db
.
Column
(
db
.
String
(
128
),
nullable
=
True
)
path
=
db
.
Column
(
db
.
String
(
128
),
nullable
=
True
)
created
=
db
.
Column
(
db
.
DateTime
,
default
=
datetime
.
datetime
.
utcnow
,
nullable
=
False
)
@classmethod
@classmethod
def
from_form
(
cls
,
filestorage
):
def
from_form
(
cls
,
filestorage
):
...
...
This diff is collapsed.
Click to expand it.
Julian
@julian
mentioned in commit
554fa727
·
Mar 12, 2023
mentioned in commit
554fa727
mentioned in commit 554fa727d861661065359d88bbdbf2670cd70262
Toggle commit list
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