From 02499e4daacfffb94c571b610c780a53c38ed5bf Mon Sep 17 00:00:00 2001 From: goat du site <72492241+aguacero7@users.noreply.github.com> Date: Wed, 2 Apr 2025 20:21:39 +0200 Subject: [PATCH] feat(ci): modif des migrations selon la branche --- .github/workflows/master.yml | 3 -- .github/workflows/test.yml | 7 +-- .gitignore | 1 + migrations/versions/6b53a099248e_test.py | 50 ++++++++++++++++++ .../3598886c6764_v3_test.cpython-39.pyc | Bin 901 -> 0 bytes 5 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 migrations/versions/6b53a099248e_test.py delete mode 100644 migrations/versions/__pycache__/3598886c6764_v3_test.cpython-39.pyc diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 3771556..a7e13f3 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -42,9 +42,6 @@ jobs: - name: Vérifier et appliquer les migrations si besoin run: | - echo "🔍 Vérification des changements dans les modèles..." - - flask db migrate -m "Migration auto" || true if git diff --quiet --exit-code -- migrations/versions; then echo "✅ Aucun changement détecté. Pas de migration à appliquer." diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0812f0b..f7a03b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,12 +39,9 @@ jobs: - name: Exécution de Pylint run: pylint $(find . -name "*.py" -not -path "./migrations/*") --disable=W - - name: Vérifier et appliquer les migrations si besoin + - name: Vérifier et appliquer les migrations générées par le workflow develop run: | - echo "🔍 Vérification des changements dans les modèles..." - - flask db migrate -m "Migration auto" || true - + #pas de migratins dans ce workflow, on upgrade la bdd if git diff --quiet --exit-code -- migrations/versions; then echo "✅ Aucun changement détecté. Pas de migration à appliquer." else diff --git a/.gitignore b/.gitignore index bee8a64..ab47253 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__ +*.pyc \ No newline at end of file diff --git a/migrations/versions/6b53a099248e_test.py b/migrations/versions/6b53a099248e_test.py new file mode 100644 index 0000000..506aa54 --- /dev/null +++ b/migrations/versions/6b53a099248e_test.py @@ -0,0 +1,50 @@ +"""test + +Revision ID: 6b53a099248e +Revises: +Create Date: 2025-04-02 19:40:19.927384 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '6b53a099248e' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('sbom') + op.drop_table('project') + with op.batch_alter_table('trivy_reports', schema=None) as batch_op: + batch_op.add_column(sa.Column('sbom_id', sa.Integer(), nullable=False)) + batch_op.create_foreign_key(None, 'sboms', ['sbom_id'], ['id']) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('trivy_reports', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_column('sbom_id') + + op.create_table('project', + sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('project_id_seq'::regclass)"), autoincrement=True, nullable=False), + sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), + sa.Column('version', sa.VARCHAR(length=50), autoincrement=False, nullable=False), + sa.PrimaryKeyConstraint('id', name='project_pkey'), + postgresql_ignore_search_path=False + ) + op.create_table('sbom', + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column('project_id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('sbom_data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['project_id'], ['project.id'], name='sbom_project_id_fkey'), + sa.PrimaryKeyConstraint('id', name='sbom_pkey') + ) + # ### end Alembic commands ### diff --git a/migrations/versions/__pycache__/3598886c6764_v3_test.cpython-39.pyc b/migrations/versions/__pycache__/3598886c6764_v3_test.cpython-39.pyc deleted file mode 100644 index ba1210bbad3fa29156a0db5f4287c99f7d7aa836..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 901 zcmZ`%!EVz)5Z$#M+jU#fg1ErN*BqLpbsE~JLa5D!0~MkOgfG^{vr1B}*J0NQDuNSS zD}Div{Q(Yq2FJZ}>Lk+~A`ODYQcZZN~HdtQxjXXfp z2M9n?0u&rU3nz7`^5`a$I+4Etm5$ip&##bc6PTq$<}rfZ}0Rwoqng+ z+TTyQNjHivkr`=H<&dE-xExjEr|5=qCIlM_-t?8#*lZ42m5(zfDz381o|uRMWO*rOg*1+4#y?v4 z{z;`Ka)edF#h=RQ1yP%r<;S2sE(_kaEZT#^tw&6<5ihu`+Qnp~ScRJF_8ckJ&azh7 zJjrZxTGKNV%%*r5_$^GSJp|%xP-Ub4D{ANC4@K`R6or4Q*ZNC6?^wB*L)m)DM`*gW zGRh99Sp`*2uf$L{>=pao1>Ce3R-k+(Yu0x$yk>nHqvom!vJA>R%S^xoFNTwRp?aiW z3MOo;&eWPs6RNAxH0w5Db{!5Clh`0^8W-9`z^7b-&PrJeqimfePBpulSa?vBFcbW~ T9YDQ-;00?m^gLQ`Hw=FPO7zp<