Skip to content
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

Ajout d'une migration pour remplir les bases vide #473

Closed
wants to merge 1 commit into from

Conversation

mrjmad
Copy link
Collaborator

@mrjmad mrjmad commented Nov 29, 2021

🌮 Objectif

On ajoute une migration qui remplie les bases vide avec une orga, un user et un token statique uniquement si les conditions suivantes sont respectées :

  • toutes les données nécessaires sont présente en venv
  • la base est vide

j'ai presque envie que l'on ne merge jamais cette PR et qu'on déploie simplement une fois la branche lorsque nécessaire.

🔍 Implémentation

  • Une liste des modifications

🏕 Amélioration continue

  • (optionnel) Une liste d'autres modifications pas en lien direct avec la PR

⚠️ Informations supplémentaires

(optionnel) Documentation, commandes à lancer, variables d'environment, etc

🖼️ Images

(optionnel) Une ou plusieurs captures d'écran

@tut-tuuut
Copy link
Member

j'ai presque envie que l'on ne merge jamais cette PR et qu'on déploie simplement une fois la branche lorsque nécessaire.

Ça va être la merdasse pour redéployer main après, non ? Il ne va pas râler parce que genre ya deux migrations "feuille" dans la base ?

Comment on lines +55 to +56
@mock.patch.dict(os.environ, {"INIT_ORGA_NAME": "Donjons et Siphons"})
@mock.patch.dict(os.environ, {"INIT_ADMIN_USERNAME": "mario.brossse@world.fr"})
Copy link
Member

Choose a reason for hiding this comment

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

Hahaha :D

@mock.patch.dict(os.environ, {"INIT_ORGA_NAME": "Donjons et Siphons"})
@mock.patch.dict(os.environ, {"INIT_ADMIN_USERNAME": "mario.brossse@world.fr"})
@mock.patch.dict(os.environ, {"INIT_ADMIN_PASSWORD": "PEACHforEVER"})
@mock.patch.dict(os.environ, {"INIT_TOKEN": "12345"})
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@mock.patch.dict(os.environ, {"INIT_TOKEN": "12345"})
@mock.patch.dict(os.environ, {"INIT_TOKEN": "123456"})

Six chiffres le token, sinon tu vas avoir des problèmes

init_token = os.environ.get("INIT_TOKEN", None)

models = [Aidant, Organisation, StaticToken, StaticDevice]
if any([model.objects.exists() for model in models]):
Copy link
Member

Choose a reason for hiding this comment

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

any() ❤️

Python ❤️

if any([model.objects.exists() for model in models]):
return None

if all([init_token, init_orga_name, init_admin_username, init_admin_password]):
Copy link
Member

Choose a reason for hiding this comment

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

all() ❤️

@mrjmad mrjmad force-pushed the jmad_init_database_with_venv branch from 88b2e13 to 42a7535 Compare November 30, 2021 09:43

dependencies = [
("aidants_connect_web", "0078_auto_20211122_1813"),
("otp_static", "__latest__"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wah… Je connaissais pas __latest__. C'top bien !

@mrjmad mrjmad force-pushed the jmad_init_database_with_venv branch from 42a7535 to 61a1b87 Compare December 1, 2021 14:59
@mrjmad mrjmad force-pushed the jmad_init_database_with_venv branch from 61a1b87 to 3adf520 Compare December 3, 2021 09:35
@mrjmad mrjmad closed this Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants