From 02f6610d7275e6150bfe016495f05d15a1656d06 Mon Sep 17 00:00:00 2001 From: francois Date: Sun, 10 May 2020 00:21:41 -0400 Subject: [PATCH] commit initial 10 mai 2020 --- .gitignore | 3 + Dockerfile | 12 + LICENSE | 19 + README.md | 2 + Verifications.ipynb | 134 +++ backup.sh | 8 + docker-entrypoint-initdb.d/init.sh | 41 + entites.py | 14 + etat_libre_entites.xmi | 933 ++++++++++++++++++ fix_sql.sh | 9 + insertion_etatdulibre.ipynb | 679 +++++++++++++ makefile | 16 + questions_entite.py | 236 +++++ uml_generated_code/postgres/adresse.sql | 23 + uml_generated_code/postgres/association.sql | 24 + .../postgres/association_adresse.sql | 20 + .../postgres/association_coordonnees.sql | 20 + .../postgres/association_logo.sql | 18 + .../postgres/association_personne.sql | 21 + uml_generated_code/postgres/coordonnees.sql | 21 + uml_generated_code/postgres/cours.sql | 20 + .../postgres/cours_coordonnees.sql | 20 + .../postgres/cours_etablissement.sql | 20 + .../postgres/cours_personne.sql | 21 + uml_generated_code/postgres/etablissement.sql | 18 + .../postgres/etablissement_adresse.sql | 20 + .../postgres/etablissement_coordonnees.sql | 20 + uml_generated_code/postgres/evenement.sql | 24 + .../postgres/evenement_association.sql | 20 + .../postgres/evenement_coordonnees.sql | 20 + .../postgres/evenement_etablissement.sql | 20 + .../postgres/evenement_personne.sql | 21 + uml_generated_code/postgres/licence.sql | 17 + uml_generated_code/postgres/logo.sql | 18 + uml_generated_code/postgres/personne.sql | 19 + .../postgres/personne_coordonnees.sql | 20 + uml_generated_code/postgres/projet.sql | 19 + .../postgres/projet_association.sql | 20 + .../postgres/projet_coordonnees.sql | 20 + .../postgres/projet_licence.sql | 20 + .../postgres/projet_personne.sql | 21 + 41 files changed, 2671 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Verifications.ipynb create mode 100644 backup.sh create mode 100644 docker-entrypoint-initdb.d/init.sh create mode 100755 entites.py create mode 100644 etat_libre_entites.xmi create mode 100644 fix_sql.sh create mode 100644 insertion_etatdulibre.ipynb create mode 100644 makefile create mode 100755 questions_entite.py create mode 100644 uml_generated_code/postgres/adresse.sql create mode 100644 uml_generated_code/postgres/association.sql create mode 100644 uml_generated_code/postgres/association_adresse.sql create mode 100644 uml_generated_code/postgres/association_coordonnees.sql create mode 100644 uml_generated_code/postgres/association_logo.sql create mode 100644 uml_generated_code/postgres/association_personne.sql create mode 100644 uml_generated_code/postgres/coordonnees.sql create mode 100644 uml_generated_code/postgres/cours.sql create mode 100644 uml_generated_code/postgres/cours_coordonnees.sql create mode 100644 uml_generated_code/postgres/cours_etablissement.sql create mode 100644 uml_generated_code/postgres/cours_personne.sql create mode 100644 uml_generated_code/postgres/etablissement.sql create mode 100644 uml_generated_code/postgres/etablissement_adresse.sql create mode 100644 uml_generated_code/postgres/etablissement_coordonnees.sql create mode 100644 uml_generated_code/postgres/evenement.sql create mode 100644 uml_generated_code/postgres/evenement_association.sql create mode 100644 uml_generated_code/postgres/evenement_coordonnees.sql create mode 100644 uml_generated_code/postgres/evenement_etablissement.sql create mode 100644 uml_generated_code/postgres/evenement_personne.sql create mode 100644 uml_generated_code/postgres/licence.sql create mode 100644 uml_generated_code/postgres/logo.sql create mode 100644 uml_generated_code/postgres/personne.sql create mode 100644 uml_generated_code/postgres/personne_coordonnees.sql create mode 100644 uml_generated_code/postgres/projet.sql create mode 100644 uml_generated_code/postgres/projet_association.sql create mode 100644 uml_generated_code/postgres/projet_coordonnees.sql create mode 100644 uml_generated_code/postgres/projet_licence.sql create mode 100644 uml_generated_code/postgres/projet_personne.sql diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8f62f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.ipynb_checkpoints/ +__pycache__/ +backup_* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8936e49 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM postgres +ENV POSTGRES_USER=etatdulibre +ENV POSTGRES_PASSWORD=etatdulibre +ENV POSTGRES_DB=etatdulibre +COPY docker-entrypoint-initdb.d /docker-entrypoint-initdb.d +COPY uml_generated_code /uml_generated_code +EXPOSE 5432 + + + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..204b93d --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a3f1dd5 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# etat_libre_2020 + diff --git a/Verifications.ipynb b/Verifications.ipynb new file mode 100644 index 0000000..ea9bf2e --- /dev/null +++ b/Verifications.ipynb @@ -0,0 +1,134 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The sql extension is already loaded. To reload it, use:\n", + " %reload_ext sql\n" + ] + } + ], + "source": [ + "%load_ext sql\n", + "%config SqlMagic.autocommit=False # for engines that do not support autommit\n", + "%sql postgresql://etatdulibre:etatdulibre@172.23.0.2/etatdulibre" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " postgresql://etatdulibre:***@172.22.0.2/etatdulibre\n", + " * postgresql://etatdulibre:***@172.23.0.2/etatdulibre\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
pers_idnomprenomprojet_idpers_id_1descriptionprojet_id_1nom_1description_1projet_id_2coord_idcoord_id_1coord_typecoord_contenu
1GoldenbergAnne11Auteur1La négociation des contributions dans les wikis publics : légitimation et politisation de la cognition collectiveThèse de doctorat122URLhttps://archipel.uqam.ca/3904/
" + ], + "text/plain": [ + "[(1, 'Goldenberg', 'Anne', 1, 1, 'Auteur', 1, 'La négociation des contributions dans les wikis publics : légitimation et politisation de la cognition collective', 'Thèse de doctorat', 1, 2, 2, 'URL', 'https://archipel.uqam.ca/3904/')]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%sql\n", + "SELECT * \n", + "FROM \"personne\" A \n", + "LEFT JOIN \"projet_personne\" B \n", + "ON A.pers_id=B.pers_id \n", + "LEFT JOIN \"projet\" C\n", + "ON B.projet_id=C.projet_id \n", + "LEFT JOIN \"projet_coordonnees\" D\n", + "ON C.projet_id=D.projet_id \n", + "LEFT JOIN \"coordonnees\" E\n", + "ON D.coord_id=E.coord_id" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..d08486c --- /dev/null +++ b/backup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +pg_dump --column-inserts \ +--data-only \ +--file "backup_20200509" \ +--host "$PG_ETATLIBRE_IP" \ +--port "5432" \ +--username "etatdulibre" \ +--blobs "etatdulibre" diff --git a/docker-entrypoint-initdb.d/init.sh b/docker-entrypoint-initdb.d/init.sh new file mode 100644 index 0000000..1f3524a --- /dev/null +++ b/docker-entrypoint-initdb.d/init.sh @@ -0,0 +1,41 @@ +#!/bin/bash + + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/logo.sql + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/adresse.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/association.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/coordonnees.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/cours.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/etablissement.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/evenement.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/licence.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/personne.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/projet.sql + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/association_adresse.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/association_coordonnees.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/association_personne.sql + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/cours_coordonnees.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/cours_etablissement.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/cours_personne.sql + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/etablissement_adresse.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/etablissement_coordonnees.sql + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/evenement_association.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/evenement_coordonnees.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/evenement_etablissement.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/evenement_personne.sql + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/personne_coordonnees.sql + +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/projet_association.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/projet_coordonnees.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/projet_licence.sql +psql -d etatdulibre -U etatdulibre --no-password -f /uml_generated_code/postgres/projet_personne.sql + +exit 0 + + diff --git a/entites.py b/entites.py new file mode 100755 index 0000000..f6ab595 --- /dev/null +++ b/entites.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Sat May 9 09:53:25 2020 + +@author: francois +""" + +from questionary import prompt +import questions_entite as qe + +entite = prompt(qe.choix_entite) + +print(entite['entite']) diff --git a/etat_libre_entites.xmi b/etat_libre_entites.xmi new file mode 100644 index 0000000..bbac4cf --- /dev/null +++ b/etat_libre_entites.xmi @@ -0,0 +1,933 @@ + + + + + umbrello uml modeller http://umbrello.kde.org + 1.6.12 + UnicodeUTF8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fix_sql.sh b/fix_sql.sh new file mode 100644 index 0000000..3635f49 --- /dev/null +++ b/fix_sql.sh @@ -0,0 +1,9 @@ +#!/bin/bash +cd ./uml_generated_code/postgres/ +for i in *.sql +do +sed 's/SET\sNOT\s0/SET NOT NULL/g' "$i" > "fix_$i" +cp "fix_$i" "$i" +rm "fix_$i" +done +cd ../../ diff --git a/insertion_etatdulibre.ipynb b/insertion_etatdulibre.ipynb new file mode 100644 index 0000000..c0fbfb0 --- /dev/null +++ b/insertion_etatdulibre.ipynb @@ -0,0 +1,679 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The sql extension is already loaded. To reload it, use:\n", + " %reload_ext sql\n" + ] + } + ], + "source": [ + "%load_ext sql\n", + "%config SqlMagic.autocommit=False # for engines that do not support autommit\n", + "%sql postgresql://etatdulibre:etatdulibre@172.23.0.2/etatdulibre" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# adresse" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.adresse(\n", + " adresse_id, numero_civique, type_rue, nom_rue, code_postal, ville, date_saisie)\n", + " VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING adresse_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# association" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.association(\n", + "\tassoc_id, logo_id, date_saisie, nom, sigle, type, description, date_fondation, date_fermeture)\n", + "\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING assoc_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# association_adresse" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.association_adresse(\n", + "\tassoc_id, adresse_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# association_coordonnees" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.association_coordonnees(\n", + "\tassoc_id, coord_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# association_personne" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.association_personne(\n", + "\tassoc_id, pers_id, description)\n", + "\tVALUES (?, ?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# coordonnees" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " * postgresql://etatdulibre:***@172.22.0.2/etatdulibre\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%sql\n", + "INSERT INTO public.coordonnees(\n", + "\tcoord_id, coord_type, coord_contenu)\n", + "\tVALUES (?, ?, ?) RETURNING coord_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# cours" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.cours(\n", + "\tcours_id, numero, nom, description)\n", + "\tVALUES (?, ?, ?, ?) RETURNING cours_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# cours_coordonnees" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.cours_coordonnees(\n", + "\tcours_id, coord_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# cours_etablissement" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.cours_etablissement(\n", + "\tcours_id, etabl_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# cours_personne" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.cours_personne(\n", + "\tcours_id, pers_id, description)\n", + "\tVALUES (?, ?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# etablissement" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.etablissement(\n", + "\tetabl_id, nom)\n", + "\tVALUES (?, ?) RETURNING etabl_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# etablissement_adresse" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.etablissement_adresse(\n", + "\tetabl_id, adresse_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# etablissement_coordonnees" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.etablissement_coordonnees(\n", + "\tetabl_id, coord_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# evenement" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.evenement(\n", + "\tevent_id, nom, date_debut, date_fin, est_recurrent, detail_recurrence, premiere_date, description)\n", + "\tVALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING event_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# evenement_association" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.evenement_association(\n", + "\tevent_id, assoc_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# evenement_coordonnees" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.evenement_coordonnees(\n", + "\tcoord_id, event_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# evenement_etablissement" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.evenement_etablissement(\n", + "\tevent_id, etabl_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# evenement_personne" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.evenement_personne(\n", + "\tevent_id, pers_id, description)\n", + "\tVALUES (?, ?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# licence" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.licence(\n", + "\tlicence_id, nom, sigle)\n", + "\tVALUES (?, ?, ?) RETURNING licence_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# logo" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.logo(\n", + "\tlogo_id, logo_url)\n", + "\tVALUES (?, ?) RETURNING logo_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# personne" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " * postgresql://etatdulibre:***@172.22.0.2/etatdulibre\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%sql\n", + "INSERT INTO public.personne(\n", + "\tpers_id, nom, prenom)\n", + "\tVALUES (?, ?, ?) RETURNING pers_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# personne_coordonnees" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " * postgresql://etatdulibre:***@172.22.0.2/etatdulibre\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%sql\n", + "INSERT INTO public.personne_coordonnees(\n", + "\tcoord_id, pers_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# projet" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " * postgresql://etatdulibre:***@172.22.0.2/etatdulibre\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%sql\n", + "INSERT INTO public.projet(\n", + "\tprojet_id, nom, description)\n", + "\tVALUES (?, ?, ?) RETURNING projet_id;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# projet_association" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.projet_association(\n", + "\tprojet_id, assoc_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# projet_coordonnees" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " * postgresql://etatdulibre:***@172.22.0.2/etatdulibre\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%sql\n", + "INSERT INTO public.projet_coordonnees(\n", + "\tprojet_id, coord_id)\n", + "\tVALUES (1, 2);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# projet_licence" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%sql\n", + "INSERT INTO public.projet_licence(\n", + "\tprojet_id, licence_id)\n", + "\tVALUES (?, ?);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# projet_personne" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " * postgresql://etatdulibre:***@172.22.0.2/etatdulibre\n", + "1 rows affected.\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%sql\n", + "INSERT INTO public.projet_personne(\n", + "\tprojet_id, pers_id, description)\n", + "\tVALUES (?, ?, ?);" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..9e810ed --- /dev/null +++ b/makefile @@ -0,0 +1,16 @@ +fix: + bash fix_sql.sh +build: + docker network create librenet + docker build --tag=etatdulibre . + docker run --name=etatdulibre --mount source=el_pgdata,target=/var/lib/postgresql/data --network=librenet -it -p 5432:5432 -p 2222:22 etatdulibre +run: + docker start etatdulibre + docker run --name=pgadminlibre --network=librenet -p 80:80 -e 'PGADMIN_DEFAULT_EMAIL=etatdulibre@librenet' -e 'PGADMIN_DEFAULT_PASSWORD=etatdulibre' -e 'PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION=True' -e 'PGADMIN_CONFIG_LOGIN_BANNER="Authorised users only!"' -e 'PGADMIN_CONFIG_CONSOLE_LOG_LEVEL=10' -d dpage/pgadmin4 +clean: + -docker stop etatdulibre pgadminlibre + -docker container rm etatdulibre pgadminlibre + -docker image rm etatdulibre + -docker network rm librenet + -docker volume rm el_pgdata + diff --git a/questions_entite.py b/questions_entite.py new file mode 100755 index 0000000..57acf44 --- /dev/null +++ b/questions_entite.py @@ -0,0 +1,236 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Sat May 9 23:18:09 2020 + +@author: francois +""" + +choix_entite = [ + { + 'type': 'list', + 'name': 'entite', + 'message': 'entite', + 'choices': [ + 'adresse', + 'association', + 'coordonnees', + 'cours', + 'etablissement', + 'evenement', + 'licence', + 'logo', + 'personne', + 'projet' + ] + } + ] + +questions_adresse = [ + { + 'type': 'input', + 'name': 'numero_civique', + 'message': 'numero_civique' + }, + { + 'type': 'list', + 'name': 'type_rue', + 'message': 'type_rue', + 'choices': [ + 'rue', + 'avenue', + 'boulevard', + 'chemin' + 'route' + '' + ] + }, + { + 'type': 'input', + 'name': 'nom_rue', + 'message': 'nom_rue' + }, + { + 'type': 'input', + 'name': 'code_postal', + 'message': 'code_postal' + }, + { + 'type': 'input', + 'name': 'ville', + 'message': 'ville' + } + ] + +questions_association = [ + { + 'type': 'input', + 'name': 'nom', + 'message': 'nom' + }, + { + 'type': 'input', + 'name': 'sigle', + 'message': 'sigle' + }, + { + 'type': 'list', + 'name': 'type', + 'message': 'type', + 'choices': [ + 'groupe d\'utilisateurs', + 'groupe de développeurs', + 'réseautage et évenementiel', + 'atelier ou fablab', + 'formation', + 'bienfaisance', + 'autre' + ] + }, + { + 'type': 'editor', + 'name': 'description', + 'message': 'description' + }, + { + 'type': 'input', + 'name': 'date_fondation', + 'message': 'date_fondation' + }, + { + 'type': 'input', + 'name': 'date_fermeture', + 'message': 'date_fermeture' + } + ] + +questions_coordonnees = [ + { + 'type': 'list', + 'name': 'coord_type', + 'message': 'coord_type', + 'choices': [ + 'url', + 'courriel', + 'telephone', + 'fax' + ] + }, + { + 'type': 'input', + 'name': 'coord_contenu', + 'message': 'coord_contenu' + } + ] + +questions_cours = [ + { + 'type': 'input', + 'name': 'numero', + 'message': 'numero' + }, + { + 'type': 'input', + 'name': 'nom', + 'message': 'nom' + }, + { + 'type': 'editor', + 'name': 'description', + 'message': 'description' + } + ] + +questions_etablissement = [ + { + 'type': 'input', + 'name': 'nom', + 'message': 'nom' + } + ] + +questions_evenement = [ + { + 'type': 'input', + 'name': 'nom', + 'message': 'nom' + }, + { + 'type': 'input', + 'name': 'date_debut', + 'message': 'date_debut' + }, + { + 'type': 'input', + 'name': 'date_fin', + 'message': 'date_fin' + }, + { + 'type': 'list', + 'name': 'est_recurrent', + 'message': 'est_recurrent', + 'choices': ['O', 'N'] + }, + { + 'type': 'input', + 'name': 'detail_recurrence', + 'message': 'detail_recurrence' + }, + { + 'type': 'input', + 'name': 'premiere_date', + 'message': 'premiere_date' + }, + { + 'type': 'editor', + 'name': 'description', + 'message': 'description' + } + ] + +questions_licence = [ + { + 'type': 'input', + 'name': 'nom', + 'message': 'nom' + }, + { + 'type': 'input', + 'name': 'sigle', + 'message': 'sigle' + } + ] + +questions_logo = [ + { + 'type': 'input', + 'name': 'logo_url', + 'message': 'logo_url' + } + ] + +questions_personne = [ + { + 'type': 'input', + 'name': 'nom', + 'message': 'nom' + }, + { + 'type': 'input', + 'name': 'prénom', + 'message': 'prénom' + } + ] + +questions_projet = [ + { + 'type': 'input', + 'name': 'nom', + 'message': 'nom' + }, + { + 'type': 'editor', + 'name': 'description', + 'message': 'description' + } + ] diff --git a/uml_generated_code/postgres/adresse.sql b/uml_generated_code/postgres/adresse.sql new file mode 100644 index 0000000..5a1b683 --- /dev/null +++ b/uml_generated_code/postgres/adresse.sql @@ -0,0 +1,23 @@ + +-- +-- TABLE: adresse +-- +-- + +CREATE TABLE adresse ( + adresse_id integer NOT NULL , + numero_civique character varying NOT NULL , + type_rue character varying NOT NULL , + nom_rue character varying NOT NULL , + code_postal character varying NOT NULL , + ville character varying NOT NULL , + date_saisie date NOT NULL +); +CREATE SEQUENCE adresse_adresse_id_seq START 1 INCREMENT 1 ; +ALTER TABLE adresse ALTER COLUMN adresse_id SET NOT 0; +ALTER TABLE adresse ALTER COLUMN adresse_id SET DEFAULT nextval('adresse_adresse_id_seq'); + +-- +ALTER TABLE adresse ADD CONSTRAINT primaire_adresse_id PRIMARY KEY (adresse_id); + +CREATE INDEX adresse_adresse_id_index ON adresse(adresse_id); diff --git a/uml_generated_code/postgres/association.sql b/uml_generated_code/postgres/association.sql new file mode 100644 index 0000000..271f848 --- /dev/null +++ b/uml_generated_code/postgres/association.sql @@ -0,0 +1,24 @@ + +-- +-- TABLE: association +-- +-- + +CREATE TABLE association ( + assoc_id integer NOT NULL , + date_saisie date NOT NULL , + nom character varying NOT NULL , + sigle character varying, + type character varying, + description character varying, + date_fondation date, + date_fermeture date +); +CREATE SEQUENCE association_assoc_id_seq START 1 INCREMENT 1 ; +ALTER TABLE association ALTER COLUMN assoc_id SET NOT 0; +ALTER TABLE association ALTER COLUMN assoc_id SET DEFAULT nextval('association_assoc_id_seq'); + +-- +ALTER TABLE association ADD CONSTRAINT primaire_assoc_id PRIMARY KEY (assoc_id); + +CREATE INDEX association_assoc_id_index ON association(assoc_id); diff --git a/uml_generated_code/postgres/association_adresse.sql b/uml_generated_code/postgres/association_adresse.sql new file mode 100644 index 0000000..3b1eb51 --- /dev/null +++ b/uml_generated_code/postgres/association_adresse.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: association_adresse +-- +-- + +CREATE TABLE association_adresse ( + assoc_id integer NOT NULL , + adresse_id integer NOT NULL +); + +-- +ALTER TABLE association_adresse ADD CONSTRAINT association_adresse_adresse FOREIGN KEY (adresse_id) REFERENCES adresse(adresse_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE association_adresse ADD CONSTRAINT nouvelle_contrainte_clé_étrangère FOREIGN KEY (assoc_id) REFERENCES association(assoc_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX association_adresse_assoc_id_index ON association_adresse(assoc_id); + +CREATE INDEX association_adresse_adresse_id_index ON association_adresse(adresse_id); diff --git a/uml_generated_code/postgres/association_coordonnees.sql b/uml_generated_code/postgres/association_coordonnees.sql new file mode 100644 index 0000000..94282db --- /dev/null +++ b/uml_generated_code/postgres/association_coordonnees.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: association_coordonnees +-- +-- + +CREATE TABLE association_coordonnees ( + assoc_id integer NOT NULL , + coord_id integer NOT NULL +); + +-- +ALTER TABLE association_coordonnees ADD CONSTRAINT association_coordonnees_association FOREIGN KEY (assoc_id) REFERENCES association(assoc_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE association_coordonnees ADD CONSTRAINT association_coordonnees_coordonnees FOREIGN KEY (coord_id) REFERENCES coordonnees(coord_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX association_coordonnees_assoc_id_index ON association_coordonnees(assoc_id); + +CREATE INDEX association_coordonnees_coord_id_index ON association_coordonnees(coord_id); diff --git a/uml_generated_code/postgres/association_logo.sql b/uml_generated_code/postgres/association_logo.sql new file mode 100644 index 0000000..8df4933 --- /dev/null +++ b/uml_generated_code/postgres/association_logo.sql @@ -0,0 +1,18 @@ + +-- +-- TABLE: association_logo +-- +-- + +CREATE TABLE association_logo ( + assoc_id integer NOT NULL , + logo_id integer NOT NULL +); + +-- +ALTER TABLE association_logo ADD CONSTRAINT association_logo_association FOREIGN KEY (assoc_id) REFERENCES association(assoc_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE association_logo ADD CONSTRAINT association_logo_logo FOREIGN KEY (logo_id) REFERENCES logo(logo_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX association_logo_assoc_id_index ON association_logo(assoc_id); diff --git a/uml_generated_code/postgres/association_personne.sql b/uml_generated_code/postgres/association_personne.sql new file mode 100644 index 0000000..09f95a6 --- /dev/null +++ b/uml_generated_code/postgres/association_personne.sql @@ -0,0 +1,21 @@ + +-- +-- TABLE: association_personne +-- +-- + +CREATE TABLE association_personne ( + assoc_id integer NOT NULL , + pers_id integer NOT NULL , + description character varying +); + +-- +ALTER TABLE association_personne ADD CONSTRAINT association_personne_association FOREIGN KEY (assoc_id) REFERENCES association(assoc_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE association_personne ADD CONSTRAINT association_personne_personne FOREIGN KEY (pers_id) REFERENCES personne(pers_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX association_personne_assoc_id_index ON association_personne(assoc_id); + +CREATE INDEX association_personne_pers_id_index ON association_personne(pers_id); diff --git a/uml_generated_code/postgres/coordonnees.sql b/uml_generated_code/postgres/coordonnees.sql new file mode 100644 index 0000000..a9843ba --- /dev/null +++ b/uml_generated_code/postgres/coordonnees.sql @@ -0,0 +1,21 @@ + +-- +-- TABLE: coordonnees +-- +-- + +CREATE TABLE coordonnees ( + coord_id integer NOT NULL , + coord_type character varying NOT NULL , + coord_contenu character varying +); +CREATE SEQUENCE coordonnees_coord_id_seq START 1 INCREMENT 1 ; +ALTER TABLE coordonnees ALTER COLUMN coord_id SET NOT 0; +ALTER TABLE coordonnees ALTER COLUMN coord_id SET DEFAULT nextval('coordonnees_coord_id_seq'); + +-- +ALTER TABLE coordonnees ADD CONSTRAINT primaire_coord_id PRIMARY KEY (coord_id); + +CREATE INDEX coordonnees_coord_id_index ON coordonnees(coord_id); + +CREATE INDEX coordonnees_coord_type_index ON coordonnees(coord_type); diff --git a/uml_generated_code/postgres/cours.sql b/uml_generated_code/postgres/cours.sql new file mode 100644 index 0000000..f60d54e --- /dev/null +++ b/uml_generated_code/postgres/cours.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: cours +-- +-- + +CREATE TABLE cours ( + cours_id integer NOT NULL , + numero character varying, + nom character varying, + description character varying +); +CREATE SEQUENCE cours_cours_id_seq START 1 INCREMENT 1 ; +ALTER TABLE cours ALTER COLUMN cours_id SET NOT 0; +ALTER TABLE cours ALTER COLUMN cours_id SET DEFAULT nextval('cours_cours_id_seq'); + +-- +ALTER TABLE cours ADD CONSTRAINT primaire_cours_id PRIMARY KEY (cours_id); + +CREATE INDEX cours_cours_id_index ON cours(cours_id); diff --git a/uml_generated_code/postgres/cours_coordonnees.sql b/uml_generated_code/postgres/cours_coordonnees.sql new file mode 100644 index 0000000..28f0c67 --- /dev/null +++ b/uml_generated_code/postgres/cours_coordonnees.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: cours_coordonnees +-- +-- + +CREATE TABLE cours_coordonnees ( + cours_id integer NOT NULL , + coord_id integer NOT NULL +); + +-- +ALTER TABLE cours_coordonnees ADD CONSTRAINT cours_coordonnees_cours FOREIGN KEY (cours_id) REFERENCES cours(cours_id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +-- +ALTER TABLE cours_coordonnees ADD CONSTRAINT cours_coordonnees_coordonnees FOREIGN KEY (coord_id) REFERENCES coordonnees(coord_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX cours_coordonnees_cours_id_index ON cours_coordonnees(cours_id); + +CREATE INDEX cours_coordonnees_coord_id_index ON cours_coordonnees(coord_id); diff --git a/uml_generated_code/postgres/cours_etablissement.sql b/uml_generated_code/postgres/cours_etablissement.sql new file mode 100644 index 0000000..deef5ef --- /dev/null +++ b/uml_generated_code/postgres/cours_etablissement.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: cours_etablissement +-- +-- + +CREATE TABLE cours_etablissement ( + cours_id integer NOT NULL , + etabl_id integer NOT NULL +); + +-- +ALTER TABLE cours_etablissement ADD CONSTRAINT cours_etablissement_cours FOREIGN KEY (cours_id) REFERENCES cours(cours_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE cours_etablissement ADD CONSTRAINT cours_etablissement_etablissement FOREIGN KEY (etabl_id) REFERENCES etablissement(etabl_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX cours_etablissement_cours_id_index ON cours_etablissement(cours_id); + +CREATE INDEX cours_etablissement_etabl_id_index ON cours_etablissement(etabl_id); diff --git a/uml_generated_code/postgres/cours_personne.sql b/uml_generated_code/postgres/cours_personne.sql new file mode 100644 index 0000000..ac67f98 --- /dev/null +++ b/uml_generated_code/postgres/cours_personne.sql @@ -0,0 +1,21 @@ + +-- +-- TABLE: cours_personne +-- +-- + +CREATE TABLE cours_personne ( + cours_id integer NOT NULL , + pers_id integer NOT NULL , + description character varying NOT NULL +); + +-- +ALTER TABLE cours_personne ADD CONSTRAINT cours_personne_cours FOREIGN KEY (cours_id) REFERENCES cours(cours_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE cours_personne ADD CONSTRAINT cours_personne_personne FOREIGN KEY (pers_id) REFERENCES personne(pers_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX cours_personne_cours_id_index ON cours_personne(cours_id); + +CREATE INDEX cours_personne_pers_id_index ON cours_personne(pers_id); diff --git a/uml_generated_code/postgres/etablissement.sql b/uml_generated_code/postgres/etablissement.sql new file mode 100644 index 0000000..8b0b0a8 --- /dev/null +++ b/uml_generated_code/postgres/etablissement.sql @@ -0,0 +1,18 @@ + +-- +-- TABLE: etablissement +-- +-- + +CREATE TABLE etablissement ( + etabl_id integer NOT NULL , + nom character varying +); +CREATE SEQUENCE etablissement_etabl_id_seq START 1 INCREMENT 1 ; +ALTER TABLE etablissement ALTER COLUMN etabl_id SET NOT 0; +ALTER TABLE etablissement ALTER COLUMN etabl_id SET DEFAULT nextval('etablissement_etabl_id_seq'); + +-- +ALTER TABLE etablissement ADD CONSTRAINT primaire_etabl_id PRIMARY KEY (etabl_id); + +CREATE INDEX etablissement_etabl_id_index ON etablissement(etabl_id); diff --git a/uml_generated_code/postgres/etablissement_adresse.sql b/uml_generated_code/postgres/etablissement_adresse.sql new file mode 100644 index 0000000..56d0cfb --- /dev/null +++ b/uml_generated_code/postgres/etablissement_adresse.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: etablissement_adresse +-- +-- + +CREATE TABLE etablissement_adresse ( + etabl_id integer NOT NULL , + adresse_id integer NOT NULL +); + +-- +ALTER TABLE etablissement_adresse ADD CONSTRAINT etablissement_adresse_etablissement FOREIGN KEY (etabl_id) REFERENCES etablissement(etabl_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE etablissement_adresse ADD CONSTRAINT etablissement_adresse_adresse FOREIGN KEY (adresse_id) REFERENCES adresse(adresse_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX etablissement_adresse_etabl_id_index ON etablissement_adresse(etabl_id); + +CREATE INDEX etablissement_adresse_adresse_id_index ON etablissement_adresse(adresse_id); diff --git a/uml_generated_code/postgres/etablissement_coordonnees.sql b/uml_generated_code/postgres/etablissement_coordonnees.sql new file mode 100644 index 0000000..9ddf756 --- /dev/null +++ b/uml_generated_code/postgres/etablissement_coordonnees.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: etablissement_coordonnees +-- +-- + +CREATE TABLE etablissement_coordonnees ( + etabl_id integer NOT NULL , + coord_id integer NOT NULL +); + +-- +ALTER TABLE etablissement_coordonnees ADD CONSTRAINT etablissement_coordonnees_etablissement FOREIGN KEY (etabl_id) REFERENCES etablissement(etabl_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE etablissement_coordonnees ADD CONSTRAINT etablissement_coordonnees_coordonnees FOREIGN KEY (coord_id) REFERENCES coordonnees(coord_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX etablissement_coordonnees_etabl_id_index ON etablissement_coordonnees(etabl_id); + +CREATE INDEX etablissement_coordonnees_coord_id_index ON etablissement_coordonnees(coord_id); diff --git a/uml_generated_code/postgres/evenement.sql b/uml_generated_code/postgres/evenement.sql new file mode 100644 index 0000000..7b33eb0 --- /dev/null +++ b/uml_generated_code/postgres/evenement.sql @@ -0,0 +1,24 @@ + +-- +-- TABLE: evenement +-- +-- + +CREATE TABLE evenement ( + event_id integer NOT NULL , + nom character varying NOT NULL , + date_debut date NOT NULL , + date_fin date NOT NULL , + est_recurrent integer NOT NULL DEFAULT 0, + detail_recurrence character varying, + premiere_date date, + description character varying +); +CREATE SEQUENCE evenement_event_id_seq START 1 INCREMENT 1 ; +ALTER TABLE evenement ALTER COLUMN event_id SET NOT 0; +ALTER TABLE evenement ALTER COLUMN event_id SET DEFAULT nextval('evenement_event_id_seq'); + +-- +ALTER TABLE evenement ADD CONSTRAINT primaire_event_id PRIMARY KEY (event_id); + +CREATE INDEX evenement_event_id_index ON evenement(event_id); diff --git a/uml_generated_code/postgres/evenement_association.sql b/uml_generated_code/postgres/evenement_association.sql new file mode 100644 index 0000000..18812dc --- /dev/null +++ b/uml_generated_code/postgres/evenement_association.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: evenement_association +-- +-- + +CREATE TABLE evenement_association ( + event_id integer NOT NULL , + assoc_id integer NOT NULL +); + +-- +ALTER TABLE evenement_association ADD CONSTRAINT evenement_association_evenement FOREIGN KEY (event_id) REFERENCES evenement(event_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE evenement_association ADD CONSTRAINT evenement_association_association FOREIGN KEY (assoc_id) REFERENCES association(assoc_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX evenement_association_event_id_index ON evenement_association(event_id); + +CREATE INDEX evenement_association_assoc_id_index ON evenement_association(assoc_id); diff --git a/uml_generated_code/postgres/evenement_coordonnees.sql b/uml_generated_code/postgres/evenement_coordonnees.sql new file mode 100644 index 0000000..9d78f0d --- /dev/null +++ b/uml_generated_code/postgres/evenement_coordonnees.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: evenement_coordonnees +-- +-- + +CREATE TABLE evenement_coordonnees ( + coord_id integer NOT NULL , + event_id integer NOT NULL +); + +-- +ALTER TABLE evenement_coordonnees ADD CONSTRAINT evenement_coordonnees_evenement FOREIGN KEY (event_id) REFERENCES evenement(event_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE evenement_coordonnees ADD CONSTRAINT evenement_coordonnees_coordonnees FOREIGN KEY (coord_id) REFERENCES coordonnees(coord_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX evenement_coordonnees_coord_id_index ON evenement_coordonnees(coord_id); + +CREATE INDEX evenement_coordonnees_event_id_index ON evenement_coordonnees(event_id); diff --git a/uml_generated_code/postgres/evenement_etablissement.sql b/uml_generated_code/postgres/evenement_etablissement.sql new file mode 100644 index 0000000..930508a --- /dev/null +++ b/uml_generated_code/postgres/evenement_etablissement.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: evenement_etablissement +-- +-- + +CREATE TABLE evenement_etablissement ( + event_id integer NOT NULL , + etabl_id integer NOT NULL +); + +-- +ALTER TABLE evenement_etablissement ADD CONSTRAINT evenement_etablissement_evenement FOREIGN KEY (event_id) REFERENCES evenement(event_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE evenement_etablissement ADD CONSTRAINT evenement_etablissement_etablissement FOREIGN KEY (etabl_id) REFERENCES etablissement(etabl_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX evenement_etablissement_event_id_index ON evenement_etablissement(event_id); + +CREATE INDEX evenement_etablissement_etabl_id_index ON evenement_etablissement(etabl_id); diff --git a/uml_generated_code/postgres/evenement_personne.sql b/uml_generated_code/postgres/evenement_personne.sql new file mode 100644 index 0000000..5c5ee47 --- /dev/null +++ b/uml_generated_code/postgres/evenement_personne.sql @@ -0,0 +1,21 @@ + +-- +-- TABLE: evenement_personne +-- +-- + +CREATE TABLE evenement_personne ( + event_id integer NOT NULL , + pers_id integer NOT NULL , + description character varying +); + +-- +ALTER TABLE evenement_personne ADD CONSTRAINT evenement_personne_evenement FOREIGN KEY (event_id) REFERENCES evenement(event_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE evenement_personne ADD CONSTRAINT evenement_personne_personne FOREIGN KEY (pers_id) REFERENCES personne(pers_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX evenement_personne_event_id_index ON evenement_personne(event_id); + +CREATE INDEX evenement_personne_pers_id_index ON evenement_personne(pers_id); diff --git a/uml_generated_code/postgres/licence.sql b/uml_generated_code/postgres/licence.sql new file mode 100644 index 0000000..fb95d16 --- /dev/null +++ b/uml_generated_code/postgres/licence.sql @@ -0,0 +1,17 @@ + +-- +-- TABLE: licence +-- +-- + +CREATE TABLE licence ( + licence_id integer NOT NULL , + nom character varying NOT NULL , + sigle character varying +); +CREATE SEQUENCE licence_licence_id_seq START 1 INCREMENT 1 ; +ALTER TABLE licence ALTER COLUMN licence_id SET NOT 0; +ALTER TABLE licence ALTER COLUMN licence_id SET DEFAULT nextval('licence_licence_id_seq'); + +-- +ALTER TABLE licence ADD CONSTRAINT primaire_licence_id PRIMARY KEY (licence_id); diff --git a/uml_generated_code/postgres/logo.sql b/uml_generated_code/postgres/logo.sql new file mode 100644 index 0000000..53e9e39 --- /dev/null +++ b/uml_generated_code/postgres/logo.sql @@ -0,0 +1,18 @@ + +-- +-- TABLE: logo +-- +-- + +CREATE TABLE logo ( + logo_id integer NOT NULL , + logo_url character varying +); +CREATE SEQUENCE logo_logo_id_seq START 1 INCREMENT 1 ; +ALTER TABLE logo ALTER COLUMN logo_id SET NOT 0; +ALTER TABLE logo ALTER COLUMN logo_id SET DEFAULT nextval('logo_logo_id_seq'); + +-- +ALTER TABLE logo ADD CONSTRAINT primaire_logo_id PRIMARY KEY (logo_id); + +CREATE INDEX logo_logo_id_index ON logo(logo_id); diff --git a/uml_generated_code/postgres/personne.sql b/uml_generated_code/postgres/personne.sql new file mode 100644 index 0000000..8ac6e0e --- /dev/null +++ b/uml_generated_code/postgres/personne.sql @@ -0,0 +1,19 @@ + +-- +-- TABLE: personne +-- +-- + +CREATE TABLE personne ( + pers_id integer NOT NULL , + nom character varying, + prenom character varying +); +CREATE SEQUENCE personne_pers_id_seq START 1 INCREMENT 1 ; +ALTER TABLE personne ALTER COLUMN pers_id SET NOT 0; +ALTER TABLE personne ALTER COLUMN pers_id SET DEFAULT nextval('personne_pers_id_seq'); + +-- +ALTER TABLE personne ADD CONSTRAINT primaire_pers_id PRIMARY KEY (pers_id); + +CREATE INDEX personne_pers_id_index ON personne(pers_id); diff --git a/uml_generated_code/postgres/personne_coordonnees.sql b/uml_generated_code/postgres/personne_coordonnees.sql new file mode 100644 index 0000000..36c299b --- /dev/null +++ b/uml_generated_code/postgres/personne_coordonnees.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: personne_coordonnees +-- +-- + +CREATE TABLE personne_coordonnees ( + coord_id integer NOT NULL , + pers_id integer NOT NULL +); + +-- +ALTER TABLE personne_coordonnees ADD CONSTRAINT personne_coordonnees_personne FOREIGN KEY (pers_id) REFERENCES personne(pers_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE personne_coordonnees ADD CONSTRAINT personne_coordonnees_coordonnees FOREIGN KEY (coord_id) REFERENCES coordonnees(coord_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX personne_coordonnees_coord_id_index ON personne_coordonnees(coord_id); + +CREATE INDEX personne_coordonnees_pers_id_index ON personne_coordonnees(pers_id); diff --git a/uml_generated_code/postgres/projet.sql b/uml_generated_code/postgres/projet.sql new file mode 100644 index 0000000..4407eb0 --- /dev/null +++ b/uml_generated_code/postgres/projet.sql @@ -0,0 +1,19 @@ + +-- +-- TABLE: projet +-- +-- + +CREATE TABLE projet ( + projet_id integer NOT NULL , + nom character varying NOT NULL , + description character varying +); +CREATE SEQUENCE projet_projet_id_seq START 1 INCREMENT 1 ; +ALTER TABLE projet ALTER COLUMN projet_id SET NOT 0; +ALTER TABLE projet ALTER COLUMN projet_id SET DEFAULT nextval('projet_projet_id_seq'); + +-- +ALTER TABLE projet ADD CONSTRAINT primaire_projet_id PRIMARY KEY (projet_id); + +CREATE INDEX projet_projet_id_index ON projet(projet_id); diff --git a/uml_generated_code/postgres/projet_association.sql b/uml_generated_code/postgres/projet_association.sql new file mode 100644 index 0000000..4ffd4fc --- /dev/null +++ b/uml_generated_code/postgres/projet_association.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: projet_association +-- +-- + +CREATE TABLE projet_association ( + projet_id integer NOT NULL , + assoc_id integer NOT NULL +); + +-- +ALTER TABLE projet_association ADD CONSTRAINT projet_association_projet FOREIGN KEY (projet_id) REFERENCES projet(projet_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE projet_association ADD CONSTRAINT projet_association_association FOREIGN KEY (assoc_id) REFERENCES association(assoc_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX projet_association_projet_id_index ON projet_association(projet_id); + +CREATE INDEX projet_association_assoc_id_index ON projet_association(assoc_id); diff --git a/uml_generated_code/postgres/projet_coordonnees.sql b/uml_generated_code/postgres/projet_coordonnees.sql new file mode 100644 index 0000000..6926969 --- /dev/null +++ b/uml_generated_code/postgres/projet_coordonnees.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: projet_coordonnees +-- +-- + +CREATE TABLE projet_coordonnees ( + projet_id integer NOT NULL , + coord_id integer NOT NULL +); + +-- +ALTER TABLE projet_coordonnees ADD CONSTRAINT projet_coordonnees_projet FOREIGN KEY (projet_id) REFERENCES projet(projet_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE projet_coordonnees ADD CONSTRAINT projet_coordonnees_coordonnees FOREIGN KEY (coord_id) REFERENCES coordonnees(coord_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX projet_coordonnees_projet_id_index ON projet_coordonnees(projet_id); + +CREATE INDEX projet_coordonnees_coord_id_index ON projet_coordonnees(coord_id); diff --git a/uml_generated_code/postgres/projet_licence.sql b/uml_generated_code/postgres/projet_licence.sql new file mode 100644 index 0000000..26850f6 --- /dev/null +++ b/uml_generated_code/postgres/projet_licence.sql @@ -0,0 +1,20 @@ + +-- +-- TABLE: projet_licence +-- +-- + +CREATE TABLE projet_licence ( + projet_id integer NOT NULL , + licence_id integer NOT NULL +); + +-- +ALTER TABLE projet_licence ADD CONSTRAINT projet_licence_projet FOREIGN KEY (projet_id) REFERENCES projet(projet_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE projet_licence ADD CONSTRAINT projet_licence_licence FOREIGN KEY (licence_id) REFERENCES licence(licence_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX projet_licence_projet_id_index ON projet_licence(projet_id); + +CREATE INDEX projet_licence_licence_id_index ON projet_licence(licence_id); diff --git a/uml_generated_code/postgres/projet_personne.sql b/uml_generated_code/postgres/projet_personne.sql new file mode 100644 index 0000000..0664caf --- /dev/null +++ b/uml_generated_code/postgres/projet_personne.sql @@ -0,0 +1,21 @@ + +-- +-- TABLE: projet_personne +-- +-- + +CREATE TABLE projet_personne ( + projet_id integer NOT NULL , + pers_id integer NOT NULL , + description character varying NOT NULL +); + +-- +ALTER TABLE projet_personne ADD CONSTRAINT projet_personne_projet FOREIGN KEY (projet_id) REFERENCES projet(projet_id) ON UPDATE CASCADE ON DELETE CASCADE; + +-- +ALTER TABLE projet_personne ADD CONSTRAINT projet_personne_personne FOREIGN KEY (pers_id) REFERENCES personne(pers_id) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE INDEX projet_personne_projet_id_index ON projet_personne(projet_id); + +CREATE INDEX projet_personne_pers_id_index ON projet_personne(pers_id);