-
-
Save CodingMarin/6bebfda60280c761cbd468acac47266e to your computer and use it in GitHub Desktop.
TGP
This file contains 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
CREATE TABLE requerimiento_geotecnia_ficha( | |
requerimiento_geotecnia_ficha_id SERIAL PRIMARY KEY, | |
requerimiento_geotecnia_id INTEGER REFERENCES requerimiento_geotecnia(requerimiento_geotecnia_id), | |
ficha_url VARCHAR(255), | |
soft_delete BOOLEAN DEFAULT false, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
) | |
CREATE TRIGGER update_requerimiento_geotecnia_ficha_updated_at | |
BEFORE UPDATE ON requerimiento_geotecnia_ficha | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE TABLE obra_geotecnia ( | |
obra_geotecnia_id SERIAL PRIMARY KEY, | |
codigo VARCHAR(100), | |
requerimiento_geotecnia_id INTEGER REFERENCES requerimiento_geotecnia(requerimiento_geotecnia_id), | |
tipo_geotecnia_id INTEGER REFERENCES tipo_geotecnia(tipo_geotecnia_id), | |
area_m2 NUMERIC, | |
observacion VARCHAR(255), | |
soft_delete BOOLEAN DEFAULT false, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
ALTER TABLE obra_geotecnia | |
ADD CONSTRAINT codigo_unique UNIQUE (codigo); | |
CREATE TRIGGER update_obra_geotecnia_updated_at | |
BEFORE UPDATE ON obra_geotecnia | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE TABLE requerimiento_geotecnia ( | |
requerimiento_geotecnia_id SERIAL PRIMARY KEY, | |
codigo VARCHAR(100), | |
informe_url VARCHAR(255), | |
empresa_id INTEGER REFERENCES empresa(empresa_id), | |
anho_requerimiento INTEGER, | |
soft_delete BOOLEAN DEFAULT FALSE, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
ALTER TABLE requerimiento_geotecnia | |
ADD CONSTRAINT codigo_unique UNIQUE (codigo); | |
CREATE TRIGGER update_requerimiento_geotecnia_updated_at | |
BEFORE UPDATE ON requerimiento_geotecnia | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE TABLE tipo_geotecnia ( | |
tipo_geotecnia_id SERIAL PRIMARY KEY, | |
descripcion VARCHAR(200), | |
grupo_geotecnia_id INTEGER REFERENCES grupo_geotecnia(grupo_geotecnia_id), | |
soft_delete BOOLEAN DEFAULT false, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
CREATE TRIGGER update_tipo_geotecnia_updated_at | |
BEFORE UPDATE ON tipo_geotecnia | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE TABLE grupo_geotecnia ( | |
grupo_geotecnia_id SERIAL PRIMARY KEY, | |
descripcion VARCHAR(200), | |
soft_delete BOOLEAN DEFAULT FALSE, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
CREATE TRIGGER update_grupo_geotecnia_updated_at | |
BEFORE UPDATE ON grupo_geotecnia | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE OR REPLACE FUNCTION update_updated_at_column() | |
RETURNS TRIGGER AS $$ | |
BEGIN | |
NEW.updated_at = NOW(); | |
RETURN NEW; | |
END; | |
$$ LANGUAGE plpgsql; | |
CREATE TABLE paquete_puntos_geodesicos ( | |
paquete_puntos_geodesicos_id SERIAL PRIMARY KEY, | |
descripcion VARCHAR(100), | |
soft_delete BOOLEAN DEFAULT FALSE, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
CREATE TRIGGER update_paquete_puntos_geodesicos_updated_at | |
BEFORE UPDATE ON paquete_puntos_geodesicos | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE TABLE certificado_puntos_geodesicos ( | |
certificado_puntos_geodesicos_id SERIAL PRIMARY KEY, | |
descripcion VARCHAR(100), | |
soft_delete BOOLEAN DEFAULT FALSE, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
CREATE TRIGGER update_certificado_puntos_geodesicos_updated_at | |
BEFORE UPDATE ON certificado_puntos_geodesicos | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE TABLE punto_geodesico ( | |
punto_geodesico_id SERIAL PRIMARY KEY, | |
codigo VARCHAR(100), | |
empresa_id INTEGER REFERENCES empresa(empresa_id), | |
fecha_levantamiento DATE, | |
paquete_puntos_geodesicos_id INTEGER REFERENCES paquete_puntos_geodesicos(paquete_puntos_geodesicos_id), | |
certificado_puntos_geodesicos_id INTEGER REFERENCES certificado_puntos_geodesicos(certificado_puntos_geodesicos_id), | |
fecha_certificado DATE, | |
utm_este VARCHAR(100), | |
utm_norte VARCHAR(100), | |
utm_zona VARCHAR(100), | |
latitud VARCHAR(100), | |
longitud VARCHAR(100), | |
ubigeo_id VARCHAR(6), | |
altura_elipsoidal VARCHAR(100), | |
informe_url VARCHAR(255), | |
certificado_url VARCHAR(255), | |
soft_delete BOOLEAN DEFAULT FALSE, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
ALTER TABLE punto_geodesico | |
ADD CONSTRAINT fk_punto_geodesico_ubigeo | |
FOREIGN KEY (ubigeo_id) | |
REFERENCES Ubigeo(codigo); | |
CREATE TRIGGER update_punto_geodesico_updated_at | |
BEFORE UPDATE ON punto_geodesico | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
CREATE TABLE punto_geodesico_fotos ( | |
punto_geodesico_fotos_id SERIAL PRIMARY KEY, | |
punto_geodesico_id INTEGER REFERENCES punto_geodesico(punto_geodesico_id), | |
foto_url VARCHAR(255), | |
soft_delete BOOLEAN DEFAULT FALSE, | |
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | |
); | |
CREATE TRIGGER update_punto_geodesico_fotos_updated_at | |
BEFORE UPDATE ON punto_geodesico_fotos | |
FOR EACH ROW | |
EXECUTE FUNCTION update_updated_at_column(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment