This repository has been archived by the owner on Aug 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kemu3007
committed
Nov 2, 2020
1 parent
b9837ca
commit 6058272
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/alembic/migrations/versions/aa8a8e0293ac_replace_nbsp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""replace   | ||
Revision ID: aa8a8e0293ac | ||
Revises: 98ecbc1e5b66 | ||
Create Date: 2020-11-02 12:48:17.045798 | ||
""" | ||
import os | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
from alembic import op | ||
from haro.plugins.create_models import Term | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'aa8a8e0293ac' | ||
down_revision = '98ecbc1e5b66' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
engine = sa.create_engine(os.environ.get("SQLALCHEMY_URL")) | ||
Session = sessionmaker(bind=engine) | ||
|
||
def upgrade(): | ||
# ハイパーリンクがTerm.wordに含まれている場合、半角スペースが\xa0になってしまっているケースが存在するため置き換える | ||
s = Session() | ||
terms = s.query(Term).filter(Term.word.like('%\xa0%')) | ||
print(terms) | ||
for term in terms: | ||
term.word = term.word.replace('\xa0', ' ') | ||
s.commit() | ||
|
||
|
||
def downgrade(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters