Skip to content

Commit

Permalink
release(2.15): fix migration process (PnX-SI#3259)
Browse files Browse the repository at this point in the history
* fix(migration): fix bad ordering of revision causing errors when migrating
* fix(migration): fix revisions that where causing problems
  • Loading branch information
jacquesfize authored Nov 19, 2024
1 parent b7234ab commit b91808b
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""update notifications import-done to make them generic with respect to the destination
Revision ID: 02e9b8758709
Revises: 5a2c9c65129f
Revises: 92f0083cf735
Create Date: 2024-01-23 16:10:58.149517
"""
Expand All @@ -12,7 +12,7 @@

# revision identifiers, used by Alembic.
revision = "02e9b8758709"
down_revision = "5a2c9c65129f"
down_revision = "92f0083cf735"
branch_labels = None
depends_on = None

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""add sensitivity filter export synthese
Revision ID: 5a2c9c65129f
Revises: 92f0083cf735
Revises: d99a7c22cc3c
Create Date: 2023-08-08 16:23:53.059110
"""
Expand All @@ -12,7 +12,7 @@

# revision identifiers, used by Alembic.
revision = "5a2c9c65129f"
down_revision = "92f0083cf735"
down_revision = "d99a7c22cc3c"
branch_labels = None
depends_on = None

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""add required conditions in import
Revision ID: 8b149244d586
Revises: ebbe0f7ed866
Revises: bfc90691737d
Create Date: 2024-03-20 11:17:57.360785
"""
Expand All @@ -12,7 +12,7 @@

# revision identifiers, used by Alembic.
revision = "8b149244d586"
down_revision = "ebbe0f7ed866"
down_revision = "bfc90691737d"
branch_labels = None
depends_on = None

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""import schema
Revision ID: 92f0083cf735
Revises: 446e902a14e7
Revises: ebbe0f7ed866
Create Date: 2023-11-07 16:06:36.745188
"""
Expand All @@ -12,7 +12,7 @@

# revision identifiers, used by Alembic.
revision = "92f0083cf735"
down_revision = "d99a7c22cc3c"
down_revision = "ebbe0f7ed866"
branch_labels = None
depends_on = ("2b0b3bd0248c",)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""add group3 inpn to synthese views
Revision ID: 9f4db1786c22
Revises: bfc90691737d
Revises: 5a2c9c65129f
Create Date: 2023-07-21 14:15:23.311469
"""
Expand All @@ -11,7 +11,7 @@

# revision identifiers, used by Alembic.
revision = "9f4db1786c22"
down_revision = "bfc90691737d"
down_revision = "5a2c9c65129f"
branch_labels = None
depends_on = ("c4415009f164",) # Taxref v15 db structure

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""declare module TAXHUB
Revision ID: ebbe0f7ed866
Revises: f1dd984bff97
Revises: 9f4db1786c22
Create Date: 2023-08-02 13:15:38.542530
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def upgrade():
sa.Column("validity_column", sa.String(64)),
sa.Column("destination_table_schema", sa.String(63)),
sa.Column("destination_table_name", sa.String(63)),
sa.Column("id_unique_column", sa.Integer, sa.ForeignKey("bib_fields.id_field")),
sa.Column("id_unique_column", sa.Integer, sa.ForeignKey("gn_imports.bib_fields.id_field")),
sa.Column(
"id_parent",
sa.Integer,
sa.ForeignKey("bib_entities.id_entity"),
sa.ForeignKey("gn_imports.bib_entities.id_entity"),
),
schema="gn_imports",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Add id_entity in users errors
Revision ID: bfc90691737d
Revises: 2b0b3bd0248c
Revises: 02e9b8758709
Create Date: 2024-02-15 16:20:57.049889
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
revision = "c1a6b0793360"
down_revision = "aed662bbd88a"
branch_labels = None
depends_on = None
depends_on = ("5e882af04ff6",)


def upgrade():
Expand Down
48 changes: 26 additions & 22 deletions install/migration/migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ echo "Copie des fichiers de configuration…"
# Copy all config files (installation, GeoNature, modules)
cp -n ${olddir}/config/*.{ini,toml} ${newdir}/config/
if [ -f "${olddir}/environ" ]; then
cp -n "${olddir}/environ" "${newdir}/environ"
cp -n "${olddir}/environ" "${newdir}/environ"
fi

if [ -d "${olddir}/custom" ]; then
Expand All @@ -77,35 +77,35 @@ fi
echo "Déplacement des anciens fichiers personnalisés ..."
# before 2.12
if [ ! -f "${newdir}/custom/css/frontend.css" ] && [ -f "${olddir}/frontend/src/assets/custom.css" ] \
&& ! cmp -s "${olddir}/frontend/src/assets/custom.css" "${newdir}/backend/static/css/frontend.css"; then
mkdir -p "${newdir}/custom/css/"
cp "${olddir}/frontend/src/assets/custom.css" "${newdir}/custom/css/frontend.css"
&& ! cmp -s "${olddir}/frontend/src/assets/custom.css" "${newdir}/backend/static/css/frontend.css"; then
mkdir -p "${newdir}/custom/css/"
cp "${olddir}/frontend/src/assets/custom.css" "${newdir}/custom/css/frontend.css"
fi
# before 2.7
if [ ! -f "${newdir}/custom/css/frontend.css" ] && [ -f "${olddir}/frontend/src/custom/custom.scss" ] \
&& ! cmp -s "${olddir}/frontend/src/custom/custom.scss" "${newdir}/backend/static/css/frontend.css"; then
mkdir -p "${newdir}/custom/css/"
cp "${olddir}/frontend/src/custom/custom.scss" "${newdir}/custom/css/frontend.css"
&& ! cmp -s "${olddir}/frontend/src/custom/custom.scss" "${newdir}/backend/static/css/frontend.css"; then
mkdir -p "${newdir}/custom/css/"
cp "${olddir}/frontend/src/custom/custom.scss" "${newdir}/custom/css/frontend.css"
fi
# before 2.12
for img in login_background.jpg logo_sidebar.jpg logo_structure.png; do
if [ ! -f "${newdir}/custom/images/${img}" ] && [ -f "${olddir}/frontend/src/custom/images/${img}" ] \
if [ ! -f "${newdir}/custom/images/${img}" ] && [ -f "${olddir}/frontend/src/custom/images/${img}" ] \
&& ! cmp -s "${olddir}/frontend/src/custom/images/${img}" "${newdir}/backend/static/images/${img}"; then
mkdir -p "${newdir}/custom/images/"
cp "${olddir}/frontend/src/custom/images/${img}" "${newdir}/custom/images/${img}"
fi
mkdir -p "${newdir}/custom/images/"
cp "${olddir}/frontend/src/custom/images/${img}" "${newdir}/custom/images/${img}"
fi
done
# before 2.12
if [ ! -f "${newdir}/custom/images/favicon.ico" ] && [ -f "${olddir}/frontend/src/favicon.ico" ] \
&& ! cmp -s "${olddir}/frontend/src/favicon.ico" "${newdir}/backend/static/images/favicon.ico"; then
mkdir -p "${newdir}/custom/images/"
cp "${olddir}/frontend/src/favicon.ico" "${newdir}/custom/images/favicon.ico"
&& ! cmp -s "${olddir}/frontend/src/favicon.ico" "${newdir}/backend/static/images/favicon.ico"; then
mkdir -p "${newdir}/custom/images/"
cp "${olddir}/frontend/src/favicon.ico" "${newdir}/custom/images/favicon.ico"
fi
# before 2.12
if [ ! -f "${newdir}/custom/css/metadata_pdf_custom.css" ] && [ -f "${olddir}/backend/static/css/custom.css" ] \
&& ! cmp -s "${olddir}/backend/static/css/custom.css" "${newdir}/backend/static/css/metadata_pdf_custom.css"; then
mkdir -p "${newdir}/custom/css/"
cp "${olddir}/backend/static/css/custom.css" "${newdir}/custom/css/metadata_pdf_custom.css"
&& ! cmp -s "${olddir}/backend/static/css/custom.css" "${newdir}/backend/static/css/metadata_pdf_custom.css"; then
mkdir -p "${newdir}/custom/css/"
cp "${olddir}/backend/static/css/custom.css" "${newdir}/custom/css/metadata_pdf_custom.css"
fi


Expand All @@ -114,7 +114,7 @@ echo "Mise à jour de node si nécessaire …"
cd "${newdir}"/install
./00_install_nvm.sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

cd "${newdir}/frontend"
nvm use
Expand All @@ -127,15 +127,19 @@ echo "Installation des dépendances node du backend …"
cd "${newdir}/backend/static"
npm ci --only=prod


echo "Mise à jour du backend …"
cd "${newdir}/install"
./01_install_backend.sh
source "${newdir}/backend/venv/bin/activate"



# before 2.15 - If gn_module_import module previously installed
if [ -f "${olddir}"/frontend/external_modules/import ];then
rm "${olddir}"/frontend/external_modules/import
if [ -d ${olddir}/frontend/external_modules/import ];then
source ${olddir}/backend/venv/bin/activate
pip uninstall gn_module_import -y # require when git enabled
rm ${olddir}/frontend/external_modules/import
source deactivate
fi

echo "Installation des modules externes …"
Expand Down Expand Up @@ -267,7 +271,7 @@ deactivate

# before 2.15 - Suppression de l'application Taxhub et de la configuration du service systemctl
if [ -f "/etc/systemd/system/taxhub.service" ]; then
sudo systemctl stop taxhub
sudo systemctl stop taxhub
sudo systemctl disable taxhub
sudo rm /etc/systemd/system/taxhub.service
sudo systemctl daemon-reload
Expand Down

0 comments on commit b91808b

Please sign in to comment.