fix: merge
This commit is contained in:
@ -21,8 +21,8 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation('org.springframework.boot:spring-boot-starter-validation')
|
||||
implementation('org.springframework.boot:spring-boot-starter-data-rest')
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
|
||||
implementation 'org.postgresql:postgresql'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
|
@ -1,43 +1,24 @@
|
||||
package enseirb.myinpulse.api;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class GetUserInfo {
|
||||
// TODO: understand how to get data
|
||||
@GetMapping("/getUserInfo")
|
||||
public Object user(Principal principal) {
|
||||
System.out.println("GetUserInfo + " + principal);
|
||||
System.out.println(SecurityContextHolder.getContext().getAuthentication());
|
||||
return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
}
|
||||
|
||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
||||
@GetMapping("/random")
|
||||
@GetMapping("/unauth/random")
|
||||
public boolean rand() {
|
||||
System.err.println("HELLO");
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
|
||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
||||
@GetMapping("/random2")
|
||||
@GetMapping("/admin/random")
|
||||
public boolean rand2() {
|
||||
System.err.println("HELLO2");
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
|
||||
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS})
|
||||
@GetMapping("/random3")
|
||||
@GetMapping("/entrepreneur/random")
|
||||
public boolean rand3() {
|
||||
System.err.println("HELLO");
|
||||
return Math.random() > 0.5;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package enseirb.myinpulse.config;
|
||||
|
||||
import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole;
|
||||
|
||||
import enseirb.myinpulse.security.KeycloakJwtRolesConverter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
@ -12,39 +16,53 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole;
|
||||
|
||||
@Configuration
|
||||
public class WebSecurityCustomConfiguration {
|
||||
// CORS configuration
|
||||
// TODO: make sure to only accept our own domains
|
||||
|
||||
@Value("${VITE_APP_URL}")
|
||||
private String frontendUrl;
|
||||
|
||||
/**
|
||||
* Configure the CORS (Cross Origin Ressource Sharing -- a security feature) configuration. The
|
||||
* only allowed website is the frontend, defined in the .env file.
|
||||
*
|
||||
* @return the CORS configuration used by the backend
|
||||
*/
|
||||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration configuration = new CorsConfiguration();
|
||||
configuration.setAllowedOrigins(List.of("*"));
|
||||
configuration.setAllowedOrigins(List.of(frontendUrl));
|
||||
configuration.setAllowedMethods(Arrays.asList("GET", "OPTIONS"));
|
||||
configuration.setAllowedHeaders(
|
||||
Arrays.asList(
|
||||
"authorization",
|
||||
"content-type",
|
||||
"x-auth-token")); // Do not remove, this fixes the CORS errors when
|
||||
// unauthenticated
|
||||
Arrays.asList("authorization", "content-type", "x-auth-token"));
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", configuration);
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the authorisation required for each path.
|
||||
*
|
||||
* <p>admin endpoints are under /admin/* and entrepreneur are under /entrepreneur/*
|
||||
*
|
||||
* <p>If endpoints dont require authentication, they are under /unauth/
|
||||
*
|
||||
* @param http automatically filled in by spring.
|
||||
* @return a securityfilterchain, automatically used by spring.
|
||||
* @throws Exception TODO: figure out when the exception are raised
|
||||
*/
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(
|
||||
authorize ->
|
||||
authorize
|
||||
.requestMatchers("/random2")
|
||||
.requestMatchers("/entrepreneur/**")
|
||||
.access(hasRole("REALM_MyINPulse-entrepreneur"))
|
||||
.requestMatchers("/random")
|
||||
.requestMatchers("/admin/**")
|
||||
.access(hasRole("REALM_MyINPulse-admin"))
|
||||
.requestMatchers("/random3")
|
||||
.requestMatchers("/unauth/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.authenticated())
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Administrateurs;
|
||||
import enseirb.myinpulse.postgres_db.repository.AdministrateursRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class AdministrateursController {
|
||||
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
||||
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class ComptesRendusController {
|
||||
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Entrepreneurs;
|
||||
import enseirb.myinpulse.postgres_db.repository.EntrepreneursRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class EntrepreneursController {
|
||||
|
||||
|
@ -2,13 +2,15 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Projets;
|
||||
import enseirb.myinpulse.postgres_db.repository.ProjetsRepository;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class ProjetsController {
|
||||
|
||||
|
@ -2,13 +2,15 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Sections;
|
||||
import enseirb.myinpulse.postgres_db.repository.SectionsRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class SectionsController {
|
||||
|
||||
|
@ -2,12 +2,14 @@ package enseirb.myinpulse.postgres_db.controller;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Utilisateurs;
|
||||
import enseirb.myinpulse.postgres_db.repository.UtilisateursRepository;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class UtilisateursController {
|
||||
|
||||
|
@ -3,6 +3,7 @@ package enseirb.myinpulse.postgres_db.model;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.PrimaryKeyJoinColumn;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package enseirb.myinpulse.postgres_db.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -12,30 +12,14 @@ import java.util.List;
|
||||
@Table(name = "rendez_vous")
|
||||
public class RendezVous {
|
||||
|
||||
@Id
|
||||
@NotNull
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id_rdv;
|
||||
|
||||
private LocalDate date_rdv;
|
||||
|
||||
private LocalTime heure_rdv;
|
||||
|
||||
private LocalTime duree_rdv;
|
||||
|
||||
@Column(length = 255)
|
||||
private String lieu_rdv;
|
||||
|
||||
private String sujet_rdv;
|
||||
|
||||
@OneToMany(mappedBy = "rendezVousEntrepreneurs", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<Entrepreneurs> ListEntrepreneurs = new ArrayList<>();
|
||||
private final List<Entrepreneurs> ListEntrepreneurs = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "rendezVousAdministrateurs", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<Administrateurs> ListAdministrateurs = new ArrayList<>();
|
||||
private final List<Administrateurs> ListAdministrateurs = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "rendezVousComptesRendus", fetch = FetchType.LAZY, orphanRemoval = true)
|
||||
private List<ComptesRendus> ListComptesRendus = new ArrayList<>();
|
||||
private final List<ComptesRendus> ListComptesRendus = new ArrayList<>();
|
||||
|
||||
@ManyToMany(
|
||||
fetch = FetchType.LAZY,
|
||||
@ -46,6 +30,20 @@ public class RendezVous {
|
||||
inverseJoinColumns = @JoinColumn(name = "id_section"))
|
||||
List<Sections> ListSections = new ArrayList<>();
|
||||
|
||||
@Id
|
||||
@NotNull
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id_rdv;
|
||||
|
||||
private LocalDate date_rdv;
|
||||
private LocalTime heure_rdv;
|
||||
private LocalTime duree_rdv;
|
||||
|
||||
@Column(length = 255)
|
||||
private String lieu_rdv;
|
||||
|
||||
private String sujet_rdv;
|
||||
|
||||
public RendezVous() {}
|
||||
|
||||
public RendezVous(
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Administrateurs;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Entrepreneurs;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Projets;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.RendezVous;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Sections;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package enseirb.myinpulse.postgres_db.repository;
|
||||
|
||||
import enseirb.myinpulse.postgres_db.model.Utilisateurs;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package enseirb.myinpulse.security;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@ -14,8 +16,6 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
public class KeycloakJwtRolesConverter implements Converter<Jwt, AbstractAuthenticationToken> {
|
||||
/** Prefix used for realm level roles. */
|
||||
public static final String PREFIX_REALM_ROLE = "ROLE_REALM_";
|
||||
|
@ -2,11 +2,7 @@ spring.application.name=myinpulse
|
||||
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:7080/realms/test/protocol/openid-connect/certs
|
||||
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:7080/realms/test
|
||||
logging.level.org.springframework.security=DEBUG
|
||||
#spring.datasource.url=jdbc:postgresql://postgres/${POSTGRES_DB}
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5433/backend_db
|
||||
spring.datasource.username=backend_db_user
|
||||
spring.datasource.password=backend_db_user_password
|
||||
spring.datasource.url=jdbc:postgresql://${DATABASE_URL}/${BACKEND_DB}
|
||||
spring.datasource.username=${BACKEND_USER}
|
||||
spring.datasource.password=${BACKEND_PASSWORD}
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||
|
||||
spring.data.rest.base-path=/my/base/path
|
@ -1,10 +1,13 @@
|
||||
TRUNCATE projets, utilisateurs, entrepreneurs, sections, rendez_vous, comptes_rendus CASCADE;
|
||||
|
||||
INSERT INTO projets (nom_projet, logo, date_creation, status_projet) VALUES
|
||||
('Eau du robinet', decode('013d7d16d7ad4fefb61bd95b765c8ceb', 'hex'), TO_DATE('01-OCT-2023', 'DD-MON-YYYY'), 'En cours'),
|
||||
('Air oxygéné', decode('150647a0984e8f228cd14b54', 'hex'), TO_DATE('04-APR-2024', 'DD-MON-YYYY'), 'En cours'),
|
||||
('Débat concours', decode('022024abd5486e245c145dda65116f', 'hex'), TO_DATE('22-NOV-2023', 'DD-MON-YYYY'), 'Suspendu'),
|
||||
('HDeirbMI', decode('ab548d6c1d595a2975e6476f544d14c55a', 'hex'), TO_DATE('07-DEC-2024', 'DD-MON-YYYY'), 'Lancement');
|
||||
INSERT INTO projets (nom_projet, logo, date_creation, status_projet)
|
||||
VALUES ('Eau du robinet', decode('013d7d16d7ad4fefb61bd95b765c8ceb', 'hex'), TO_DATE('01-OCT-2023', 'DD-MON-YYYY'),
|
||||
'En cours'),
|
||||
('Air oxygéné', decode('150647a0984e8f228cd14b54', 'hex'), TO_DATE('04-APR-2024', 'DD-MON-YYYY'), 'En cours'),
|
||||
('Débat concours', decode('022024abd5486e245c145dda65116f', 'hex'), TO_DATE('22-NOV-2023', 'DD-MON-YYYY'),
|
||||
'Suspendu'),
|
||||
('HDeirbMI', decode('ab548d6c1d595a2975e6476f544d14c55a', 'hex'), TO_DATE('07-DEC-2024', 'DD-MON-YYYY'),
|
||||
'Lancement');
|
||||
|
||||
INSERT INTO utilisateurs (nom_utilisateur, prenom_utilisateur, mail_principal, mail_secondaire, numero_telephone) VALUES
|
||||
('Dupont', 'Dupond', 'super@mail.fr', 'super2@mail.fr', '06 45 72 45 98'),
|
||||
|
@ -10,12 +10,13 @@ DROP TABLE IF EXISTS formes CASCADE;
|
||||
|
||||
CREATE TABLE projets
|
||||
(
|
||||
id_projet SERIAL NOT NULL,
|
||||
nom_projet VARCHAR(255) ,
|
||||
logo BYTEA ,
|
||||
date_creation DATE ,
|
||||
status_projet VARCHAR(255) ,
|
||||
CONSTRAINT pk_projet PRIMARY KEY (id_projet) );
|
||||
id_projet SERIAL NOT NULL,
|
||||
nom_projet VARCHAR(255),
|
||||
logo BYTEA,
|
||||
date_creation DATE,
|
||||
status_projet VARCHAR(255),
|
||||
CONSTRAINT pk_projet PRIMARY KEY (id_projet)
|
||||
);
|
||||
|
||||
CREATE TABLE utilisateurs
|
||||
(
|
||||
@ -29,87 +30,99 @@ CONSTRAINT pk_utilisateur PRIMARY KEY (id_utilisateur) );
|
||||
|
||||
CREATE TABLE entrepreneurs
|
||||
(
|
||||
ecole VARCHAR(255) ,
|
||||
filiere VARCHAR(255) ,
|
||||
status_snee BOOLEAN ,
|
||||
CONSTRAINT pk_entrepreneur PRIMARY KEY (id_utilisateur),
|
||||
INHERITS (utilisateurs) );
|
||||
id_entrepreneur SERIAL REFERENCES utilisateurs (id_utilisateur),
|
||||
ecole VARCHAR(255),
|
||||
filiere VARCHAR(255),
|
||||
status_snee BOOLEAN,
|
||||
CONSTRAINT pk_entrepreneur PRIMARY KEY (id_entrepreneur)
|
||||
);
|
||||
|
||||
CREATE TABLE administrateurs
|
||||
(
|
||||
CONSTRAINT pk_administrateur PRIMARY KEY (id_utilisateur),
|
||||
INHERITS (utilisateurs) );
|
||||
id_administrateur SERIAL REFERENCES utilisateurs (id_utilisateur),
|
||||
CONSTRAINT pk_administrateur PRIMARY KEY (id_administrateur)
|
||||
);
|
||||
|
||||
CREATE TABLE sections
|
||||
(
|
||||
id_section SERIAL NOT NULL,
|
||||
titre VARCHAR(255) ,
|
||||
contenu_section TEXT ,
|
||||
date_modification TIMESTAMP ,
|
||||
CONSTRAINT pk_section PRIMARY KEY (id_section) );
|
||||
id_section SERIAL NOT NULL,
|
||||
titre VARCHAR(255),
|
||||
contenu_section TEXT,
|
||||
date_modification TIMESTAMP,
|
||||
CONSTRAINT pk_section PRIMARY KEY (id_section)
|
||||
);
|
||||
|
||||
CREATE TABLE rendez_vous
|
||||
(
|
||||
id_rdv SERIAL NOT NULL,
|
||||
date_rdv DATE ,
|
||||
heure_rdv TIME ,
|
||||
duree_rdv TIME ,
|
||||
lieu_rdv VARCHAR(255) ,
|
||||
sujet_rdv TEXT ,
|
||||
CONSTRAINT pk_rdv PRIMARY KEY (id_rdv) );
|
||||
id_rdv SERIAL NOT NULL,
|
||||
date_rdv DATE,
|
||||
heure_rdv TIME,
|
||||
duree_rdv TIME,
|
||||
lieu_rdv VARCHAR(255),
|
||||
sujet_rdv TEXT,
|
||||
CONSTRAINT pk_rdv PRIMARY KEY (id_rdv)
|
||||
);
|
||||
|
||||
CREATE TABLE comptes_rendus
|
||||
CREATE TABLE comptes_rendus
|
||||
(
|
||||
id_compte_rendu SERIAL NOT NULL,
|
||||
contenu_compte_rendu TEXT ,
|
||||
CONSTRAINT pk_compte_rendu PRIMARY KEY (id_compte_rendu) );
|
||||
id_compte_rendu SERIAL NOT NULL,
|
||||
contenu_compte_rendu TEXT,
|
||||
CONSTRAINT pk_compte_rendu PRIMARY KEY (id_compte_rendu)
|
||||
);
|
||||
|
||||
CREATE TABLE concerner
|
||||
(
|
||||
id_section SERIAL REFERENCES sections (id_section),
|
||||
id_rdv SERIAL REFERENCES sections (id_rdv),
|
||||
CONSTRAINT pk_concerner PRIMARY KEY (id_section, id_rdv) );
|
||||
id_section SERIAL REFERENCES sections (id_section),
|
||||
id_rdv SERIAL REFERENCES sections (id_rdv),
|
||||
CONSTRAINT pk_concerner PRIMARY KEY (id_section, id_rdv)
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE projets
|
||||
ADD CONSTRAINT fk1_projet FOREIGN KEY (id_administrateur)
|
||||
REFERENCES administrateurs (id_administrateur)
|
||||
ON DELETE CASCADE;
|
||||
ADD CONSTRAINT fk1_projet FOREIGN KEY (id_administrateur)
|
||||
REFERENCES administrateurs (id_administrateur)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE projets
|
||||
ADD CONSTRAINT fk2_projet FOREIGN KEY (id_entrepreneur_participation)
|
||||
REFERENCES entrepreneurs (id_entrepreneur)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE entrepreneurs
|
||||
ADD CONSTRAINT fk1_entrepreneur FOREIGN KEY (id_projet_propose)
|
||||
REFERENCES projets (id_projet)
|
||||
ON DELETE CASCADE;
|
||||
ALTER TABLE entrepreneurs
|
||||
ADD CONSTRAINT fk1_entrepreneur FOREIGN KEY (id_projet_propose)
|
||||
REFERENCES projets (id_projet)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE sections
|
||||
ADD CONSTRAINT fk1_section FOREIGN KEY (id_projet)
|
||||
REFERENCES projets (id_projet)
|
||||
ON DELETE CASCADE;
|
||||
ALTER TABLE sections
|
||||
ADD CONSTRAINT fk1_section FOREIGN KEY (id_projet)
|
||||
REFERENCES projets (id_projet)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE sections
|
||||
ADD CONSTRAINT fk2_section FOREIGN KEY (id_administrateur)
|
||||
REFERENCES administrateurs (id_administrateur)
|
||||
ON DELETE CASCADE;
|
||||
ALTER TABLE sections
|
||||
ADD CONSTRAINT fk2_section FOREIGN KEY (id_administrateur)
|
||||
REFERENCES administrateurs (id_administrateur)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE rendez-vous
|
||||
ADD CONSTRAINT fk1_rdv FOREIGN KEY (id_entrepreneur)
|
||||
REFERENCES entrepreneurs (id_entrepreneur)
|
||||
ON DELETE CASCADE;
|
||||
ALTER TABLE rendez-vous
|
||||
ADD CONSTRAINT fk1_rdv FOREIGN KEY (id_entrepreneur)
|
||||
REFERENCES entrepreneurs (id_entrepreneur)
|
||||
ON
|
||||
DELETE
|
||||
CASCADE;
|
||||
|
||||
ALTER TABLE rendez-vous
|
||||
ADD CONSTRAINT fk2_rdv FOREIGN KEY (id_administrateur)
|
||||
REFERENCES administrateurs (id_administrateur)
|
||||
ON DELETE CASCADE;
|
||||
ALTER TABLE rendez-vous
|
||||
ADD CONSTRAINT fk2_rdv FOREIGN KEY (id_administrateur)
|
||||
REFERENCES administrateurs (id_administrateur)
|
||||
ON
|
||||
DELETE
|
||||
CASCADE;
|
||||
|
||||
ALTER TABLE comptes-rendus
|
||||
ADD CONSTRAINT fk1_compte_rendu FOREIGN KEY (id_rdv)
|
||||
REFERENCES rendez_vous (id_rdv)
|
||||
ON DELETE CASCADE;
|
||||
ALTER TABLE comptes-rendus
|
||||
ADD CONSTRAINT fk1_compte_rendu FOREIGN KEY (id_rdv)
|
||||
REFERENCES rendez_vous (id_rdv)
|
||||
ON
|
||||
DELETE
|
||||
CASCADE;
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user