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 ba1210b..0000000 Binary files a/migrations/versions/__pycache__/3598886c6764_v3_test.cpython-39.pyc and /dev/null differ