Repository navigation
Migrations schema #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,16 @@ | ||
| # POSTGRES | ||
| POSTGRES_PASSWORD=admin | ||
| POSTGRES_USER=admin | ||
| POSTGRES_DB=administration | ||
|
|
||
| # NOCODB | ||
| NC_AUTH_JWT_SECRET=secret | ||
| NC_DB=pg://db:5432?u=admin&p=admin&d=administration | ||
| NC_ATTACHMENT_FIELD_SIZE=20971520 # default = 20 MB | ||
| NC_SECURE_ATTACHMENTS=false | ||
| NC_ALLOW_LOCAL_HOOKS=true | ||
|
|
||
| # YOYO-MIGRATION | ||
| YOYO_DB=postgresql+psycopg://localhost:5432?user=admin&password=admin&database=adapt_explore | ||
| YOYO_SRC=migrations | ||
| YOYO_VERBOSITY=2 |
This file contains hidden or 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 @@ | ||
| .env |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,34 +1,61 @@ | ||
| # Template DataForGood | ||
| # Adpat Explore | ||
|
|
||
| This file will become your README and also the index of your | ||
| documentation. | ||
|  | ||
|
|
||
| # Contributing | ||
| ## ETL | ||
|
|
||
| ## Installation | ||
| Dans le dossier `./backend`, un projet en python | ||
|
|
||
| - [Installation de Python](#installation-de-python) | ||
| ## Application | ||
|
|
||
| Ce projet utilise [uv](https://docs.astral.sh/uv/) pour la gestion des dépendances Python. Il est préréquis pour l'installation de ce projet. | ||
| Dans le dossier `./frontend`, un projet en NextJS | ||
|
|
||
| Une fois installé, il suffit de lancer la commande suivante pour installer la version de Python adéquate, créer un environnement virtuel et installer les dépendances du projet. | ||
| ## Application administration | ||
|
|
||
| ```bash | ||
| uv sync | ||
| Nous utilisont [NocoDB](https://docs.nocodb.com/) comme application d'administration. NocoDB est démarré via `compose.yml` | ||
|
|
||
| Une fois démarrée l'application est disponible sur `http://localhost:3333`. | ||
|
|
||
| Aucun paramétrages n'aient fait au démarrage de l'application donc à son premier lancement il vous faudra : | ||
|
|
||
| - Créer un utilisateur super admin | ||
| - Créer une intégration de la base de données `adpat_explore` | ||
| - Ajouter cette intégration comme source de donnée | ||
|
|
||
| ## Variables d'environnement | ||
|
|
||
| Copier le fichier `.env.example` et créer un fichier `.env` | ||
|
|
||
| ``` | ||
| cp .env.example .env | ||
| ``` | ||
|
|
||
| A l'usage, si vous utilisez VSCode, l'environnement virtuel sera automatiquement activé lorsque vous ouvrirez le projet. Sinon, il suffit de l'activer manuellement avec la commande suivante : | ||
| ## Démarrer l'infrascruture | ||
|
|
||
| ```bash | ||
| source .venv/bin/activate | ||
| ``` | ||
| podman compose up -d | ||
| # OU | ||
| docker compose up -d | ||
| ``` | ||
|
|
||
| ## Migration de schema | ||
|
|
||
| Ou alors, utilisez la commande `uv run ...` (au lieu de `python ...`) pour lancer un script Python. Par exemple: | ||
| Les migrations de schema sont gérer par [yoyo-migrations](https://ollycope.com/software/yoyo/latest/#). | ||
|
|
||
| ```bash | ||
| uv run pipelines/run.py run build_database | ||
| Dans le dossier `./database`, si c'est le premier lancement installez les dépendances | ||
|
|
||
| ``` | ||
| uv sync | ||
| ``` | ||
|
|
||
| ## Utiliser Tox pour tester votre code | ||
| Vérifier que la base de données est démarrée (cf. Démarrer l'infrascruture) et jouer les migrations | ||
|
|
||
| tox -vv | ||
| ``` | ||
| uv run --env-file ../.env yoyo apply | ||
| ``` | ||
|
|
||
| Pour ajouter un nouveau fichier de migration | ||
|
|
||
| ``` | ||
| uv run --env-file ../.env yoyo new --sql -m "..." | ||
| ``` | ||
This file contains hidden or 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 @@ | ||
| 3.14 |
This file contains hidden or 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,23 @@ | ||
| services: | ||
| db: | ||
| image: postgres:18-alpine | ||
| env_file: .env | ||
| ports: | ||
| - 5432:5432 | ||
| volumes: | ||
| - ./database/postgres-init:/docker-entrypoint-initdb.d:Z | ||
| healthcheck: | ||
| interval: 10s | ||
| retries: 10 | ||
| test: 'pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"' | ||
| timeout: 2s | ||
| admin: | ||
| image: nocodb/nocodb:2026.10.1 | ||
| env_file: .env | ||
| environment: | ||
| NODE_ENV: production # required even in dev mode, "development" value throw an error | ||
| ports: | ||
| - 3333:3333 | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy |
This file contains hidden or 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 @@ | ||
| .venv |
This file contains hidden or 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 @@ | ||
| 3.14 |
This file contains hidden or 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 @@ | ||
| CREATE DATABASE adapt_explore; |
This file contains hidden or 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,10 @@ | ||
| [project] | ||
| name = "database" | ||
| version = "0.1.0" | ||
| description = "Add your description here" | ||
| readme = "README.md" | ||
| requires-python = ">=3.14" | ||
| dependencies = [ | ||
| "psycopg[binary,pool]>=3.3.8", | ||
| "yoyo-migrations>=9.0.0", | ||
| ] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,5 @@ | ||
| [DEFAULT] | ||
| sources = %(YOYO_SRC)s | ||
| database = %(YOYO_DB)s | ||
| batch_mode = off | ||
| verbosity = %(YOYO_VERBOSITY)s | ||
|
Yopadd marked this conversation as resolved.
Resolved
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.