Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
podqast
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
Service Desk
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
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
Cy8aer
podqast
Commits
0e3a8cab
Commit
0e3a8cab
authored
3 years ago
by
Thilo Kogge
Browse files
Options
Downloads
Patches
Plain Diff
fixed linter errors
parent
805a0ae5
No related branches found
No related tags found
2 merge requests
!70
fixed 304 logic
,
!69
db model updates
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/podcast/data_migration.py
+8
-7
8 additions, 7 deletions
python/podcast/data_migration.py
python/podcast/podcast.py
+4
-0
4 additions, 0 deletions
python/podcast/podcast.py
with
12 additions
and
7 deletions
python/podcast/data_migration.py
+
8
−
7
View file @
0e3a8cab
...
...
@@ -62,7 +62,7 @@ def run_migrations(strict=True):
for
podcast_url
in
podcasts
:
podcast_dict
=
Factory
().
get_store
().
get
(
podcast_url
).
__dict__
if
podcast_dict
!=
None
:
podcast
,
entry_hashs
=
migrate_podcast_v0_v1
(
podcast_dict
,
strict
)
podcast
,
entry_hashs
=
migrate_podcast_v0_v1
(
podcast_dict
,
strict
)
for
entry_id
,
podpost
in
entry_hashs
.
items
():
if
not
podpost
.
id
:
raise
ValueError
(
"
Podpost has no id
"
)
...
...
@@ -81,7 +81,7 @@ def run_migrations(strict=True):
migrate_external_v0_v1
(
post_hash_to_id
)
set_versionnumber
(
1
)
if
current_version
<
2
:
if
current_version
<
2
and
start_version
==
1
:
from
playhouse.migrate
import
SqliteMigrator
migrator
=
SqliteMigrator
(
db
)
logger
.
info
(
"
migration2: Starting migration of the datamodel...
"
)
...
...
@@ -94,8 +94,8 @@ def run_migrations(strict=True):
migrator
.
add_index
(
"
podcast
"
,
Podcast
.
url
.
column_name
)
)
db
.
pragma
(
"
foreign_keys
"
,
"
on
"
)
set_versionnumber
(
2
)
pyotherside
.
send
(
"
migrationDone
"
)
set_versionnumber
(
2
)
pyotherside
.
send
(
"
migrationDone
"
)
def
recreate_table
(
table
:
Type
[
Model
],
tablename
:
str
):
...
...
@@ -105,7 +105,7 @@ def recreate_table(table: Type[Model], tablename: str):
db
.
execute_sql
(
"
ALTER TABLE %s RENAME TO %s;
"
%
(
tablename
,
table_copy_name
))
db
.
create_tables
([
table
])
sql
=
"
INSERT INTO %s (%s) SELECT %s FROM %s;
"
%
(
tablename
,
col_names
,
col_names
,
table_copy_name
)
#todo: check for returned sql errors
#
todo: check for returned sql errors
db
.
execute_sql
(
sql
)
logger
.
info
(
"
deleting copy of table %s
"
,
tablename
)
db
.
execute_sql
(
"
DROP TABLE %s_x;
"
%
tablename
)
...
...
@@ -181,7 +181,7 @@ def migrate_podpost_v0_v1(post_dict: dict, podpost: Podpost):
PodpostFactory
().
persist
(
podpost
)
def
migrate_podcast_v0_v1
(
podcast_dict
:
dict
,
strict
=
True
)
->
Tuple
[
Podcast
,
Dict
[
str
,
Podpost
]]:
def
migrate_podcast_v0_v1
(
podcast_dict
:
dict
,
strict
=
True
)
->
Tuple
[
Podcast
,
Dict
[
str
,
Podpost
]]:
logger
.
info
(
"
migrating podcast
'
%s
'
to new format version 1 strictmode: %s
"
,
podcast_dict
[
'
title
'
],
strict
)
try
:
if
podcast_dict
[
'
logo_path
'
]:
...
...
@@ -239,7 +239,8 @@ def migrate_podcast_v0_v1(podcast_dict: dict, strict = True) -> Tuple[Podcast, D
raise
ValueError
(
"
Migration failed. Expected %d entries, but only migrated %d
"
,
old_entry_count
,
len
(
podcast
.
entry_ids_old_to_new
))
except
Exception
as
e
:
logger
.
exception
(
"
error while migrating podcast %s to new format. strictmode: %s
"
,
podcast_dict
[
'
title
'
],
strict
)
logger
.
exception
(
"
error while migrating podcast %s to new format. strictmode: %s
"
,
podcast_dict
[
'
title
'
],
strict
)
raise
e
...
...
This diff is collapsed.
Click to expand it.
python/podcast/podcast.py
+
4
−
0
View file @
0e3a8cab
...
...
@@ -10,6 +10,10 @@ from peewee import CharField, TextField, BooleanField, IntegerField, ModelSelect
sys
.
path
.
append
(
"
/usr/share/podqast/python
"
)
from
typing
import
TYPE_CHECKING
if
TYPE_CHECKING
:
from
podpost
import
Podpost
from
podcast.constants
import
Constants
,
BaseModel
from
podcast.factory
import
BaseFactory
...
...
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