Skip to content

Commit

Permalink
db: alembic
Browse files Browse the repository at this point in the history
  • Loading branch information
polomarcus committed Sep 12, 2024
1 parent c99a1a1 commit 3e0a13b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,11 @@ Using [Alembic](https://alembic.sqlalchemy.org/en/latest/autogenerate.html) Auto

```
# If changes have already been applied (on your feature vranch) and you have to recreate your alembic file by doing :
# 1. change to your main branch (git switch main)
# 1. change to your main branch
git switch main
# 2. start test container and run "pytest -vv -k api" to rebuild the state of the DB (or drop table the table you want)
# 3. rechange to your WIP branch
# 3. rechange to your WIP branch
git switch -
# 4. connect to the test container : docker compose up test -d / docker compose exec test bash
# 5. reapply the latest saved state :
poetry run alembic stamp head
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Add new column test for table keywords
Revision ID: a5c39db3c8e9
Revises: 5ccd746ee292
Create Date: 2024-09-12 14:10:26.305593
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'a5c39db3c8e9'
down_revision: Union[str, None] = '5ccd746ee292'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Add new column number_of_keywords climat/biod/r
Revision ID: af956a85658f
Revises: a5c39db3c8e9
Create Date: 2024-09-12 14:15:12.049367
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'af956a85658f'
down_revision: Union[str, None] = 'a5c39db3c8e9'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('keywords', sa.Column('number_of_keywords_climat', sa.Integer(), nullable=True))
op.add_column('keywords', sa.Column('number_of_keywords_biodiversite', sa.Integer(), nullable=True))
op.add_column('keywords', sa.Column('number_of_keywords_ressources', sa.Integer(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('keywords', 'number_of_keywords_ressources')
op.drop_column('keywords', 'number_of_keywords_biodiversite')
op.drop_column('keywords', 'number_of_keywords_climat')
# ### end Alembic commands ###

1 comment on commit 3e0a13b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
postgres
   insert_data.py43784%36–38, 56–58, 63
   insert_existing_data_example.py19384%25–27
postgres/schemas
   models.py1501093%124–131, 143–144, 202–203, 217–218
quotaclimat/data_ingestion
   scrap_sitemap.py1341787%27–28, 33–34, 66–71, 95–97, 138–140, 202, 223–228
quotaclimat/data_ingestion/ingest_db
   ingest_sitemap_in_db.py553733%21–42, 45–58, 62–73
quotaclimat/data_ingestion/scrap_html
   scrap_description_article.py36392%19–20, 32
quotaclimat/data_processing/mediatree
   api_import.py21113237%44–48, 53–69, 73–76, 82, 85–126, 132–147, 151–152, 165–177, 181–187, 200–212, 215–219, 225, 261–262, 265–301, 304–306
   channel_program.py1575664%28–30, 41–43, 60–61, 64–66, 93, 105, 114, 154–195
   config.py15287%7, 16
   detect_keywords.py209896%222, 272–279
   update_pg_keywords.py543928%14–100, 125–129, 152–178, 184
   utils.py692268%27–51, 54, 63, 84–85
quotaclimat/utils
   healthcheck_config.py291452%22–24, 27–38
   logger.py241154%22–24, 28–37
   sentry.py11282%22–23
TOTAL124236371% 

Tests Skipped Failures Errors Time
87 0 💤 0 ❌ 0 🔥 1m 35s ⏱️

Please sign in to comment.