BEGIN; CREATE TABLE "CertamenTabasco_pais" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL ) ; CREATE TABLE "CertamenTabasco_estado" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL, "pais_id" integer NOT NULL REFERENCES "CertamenTabasco_pais" ("id") DEFERRABLE INITIALLY DEFERRED ) ; CREATE TABLE "CertamenTabasco_municipio" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL, "estado_id" integer NOT NULL REFERENCES "CertamenTabasco_estado" ("id") DEFERRABLE INITIALLY DEFERRED ) ; CREATE TABLE "CertamenTabasco_criterio" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL ) ; CREATE TABLE "CertamenTabasco_estatus" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL ) ; CREATE TABLE "CertamenTabasco_evento" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL, "fecha" date, "observaciones" text NOT NULL ) ; CREATE TABLE "CertamenTabasco_rol" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL ) ; CREATE TABLE "CertamenTabasco_juez" ( "user_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "ocupacion" varchar(150) NOT NULL, "evento_id" integer NOT NULL REFERENCES "CertamenTabasco_evento" ("id") DEFERRABLE INITIALLY DEFERRED, "rol_id" integer NOT NULL REFERENCES "CertamenTabasco_rol" ("id") DEFERRABLE INITIALLY DEFERRED, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "direccion" text NOT NULL ) ; CREATE TABLE "CertamenTabasco_notario" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL, "apellido_paterno" varchar(150) NOT NULL, "apellido_materno" varchar(150) NOT NULL, "direccion" text NOT NULL, "telefono" varchar(15) NOT NULL, "correo" varchar(75) NOT NULL, "fecha_de_nacimiento" date NOT NULL, "municipio_id" integer NOT NULL REFERENCES "CertamenTabasco_municipio" ("id") DEFERRABLE INITIALLY DEFERRED, "evento_id" integer NOT NULL REFERENCES "CertamenTabasco_evento" ("id") DEFERRABLE INITIALLY DEFERRED ) ; CREATE TABLE "CertamenTabasco_persona" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL, "apellido_paterno" varchar(150) NOT NULL, "apellido_materno" varchar(150) NOT NULL, "direccion" text NOT NULL, "telefono" varchar(15) NOT NULL, "correo" varchar(75) NOT NULL, "fecha_de_nacimiento" date NOT NULL, "municipio_id" integer NOT NULL REFERENCES "CertamenTabasco_municipio" ("id") DEFERRABLE INITIALLY DEFERRED ) ; CREATE TABLE "CertamenTabasco_imagen" ( "id" serial NOT NULL PRIMARY KEY, "municipio_id" integer NOT NULL REFERENCES "CertamenTabasco_municipio" ("id") DEFERRABLE INITIALLY DEFERRED, "titulo" varchar(150) NOT NULL, "fecha_registro" date NOT NULL, "imagen" varchar(100) NOT NULL ) ; CREATE TABLE "CertamenTabasco_tipo_ronda" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL, "calificacion_maxima_criterio" numeric(5, 2) NOT NULL ) ; CREATE TABLE "CertamenTabasco_comentario" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "remitente_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "destinatario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "fecha" timestamp with time zone NOT NULL, "mensaje" text NOT NULL ) ; CREATE TABLE "CertamenTabasco_ronda_evento" ( "id" serial NOT NULL PRIMARY KEY, "ronda_id" integer NOT NULL, "evento_id" integer NOT NULL REFERENCES "CertamenTabasco_evento" ("id") DEFERRABLE INITIALLY DEFERRED, UNIQUE ("ronda_id", "evento_id") ) ; CREATE TABLE "CertamenTabasco_ronda" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "ronda_padre_id" integer, "descripcion" varchar(150) NOT NULL, "tipo_ronda_id" integer NOT NULL REFERENCES "CertamenTabasco_tipo_ronda" ("id") DEFERRABLE INITIALLY DEFERRED, "participantes_entrada" numeric(4, 0) NOT NULL, "participantes_salida" numeric(4, 0) NOT NULL ) ; ALTER TABLE "CertamenTabasco_ronda_evento" ADD CONSTRAINT "ronda_id_refs_id_1ab389c8" FOREIGN KEY ("ronda_id") REFERENCES "CertamenTabasco_ronda" ("id") DEFERRABLE INITIALLY DEFERRED; ALTER TABLE "CertamenTabasco_ronda" ADD CONSTRAINT "ronda_padre_id_refs_id_219713f5" FOREIGN KEY ("ronda_padre_id") REFERENCES "CertamenTabasco_ronda" ("id") DEFERRABLE INITIALLY DEFERRED; CREATE TABLE "CertamenTabasco_participante" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "nombre" varchar(150) NOT NULL, "apellido_paterno" varchar(150) NOT NULL, "apellido_materno" varchar(150) NOT NULL, "direccion" text NOT NULL, "telefono" varchar(15) NOT NULL, "correo" varchar(75) NOT NULL, "fecha_de_nacimiento" date NOT NULL, "municipio_id" integer NOT NULL REFERENCES "CertamenTabasco_municipio" ("id") DEFERRABLE INITIALLY DEFERRED, "estatura" numeric(5, 2) NOT NULL, "peso" numeric(5, 2) NOT NULL, "medidas" varchar(11) NOT NULL, "pasatiempos" text NOT NULL, "ronda_id" integer NOT NULL REFERENCES "CertamenTabasco_ronda" ("id") DEFERRABLE INITIALLY DEFERRED, "estatus_id" integer REFERENCES "CertamenTabasco_estatus" ("id") DEFERRABLE INITIALLY DEFERRED, "padre_id" integer NOT NULL REFERENCES "CertamenTabasco_persona" ("id") DEFERRABLE INITIALLY DEFERRED, "madre_id" integer NOT NULL REFERENCES "CertamenTabasco_persona" ("id") DEFERRABLE INITIALLY DEFERRED, "escolaridad" varchar(250) NOT NULL, "edad" integer NOT NULL, "imagen_id" integer NOT NULL REFERENCES "CertamenTabasco_imagen" ("id") DEFERRABLE INITIALLY DEFERRED ) ; CREATE TABLE "CertamenTabasco_calificacion" ( "id" serial NOT NULL PRIMARY KEY, "fecha_registro" date NOT NULL, "usuario_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED, "activo" boolean NOT NULL, "evento_id" integer NOT NULL REFERENCES "CertamenTabasco_evento" ("id") DEFERRABLE INITIALLY DEFERRED, "participante_id" integer NOT NULL REFERENCES "CertamenTabasco_participante" ("id") DEFERRABLE INITIALLY DEFERRED, "juez_id" integer NOT NULL REFERENCES "CertamenTabasco_juez" ("user_ptr_id") DEFERRABLE INITIALLY DEFERRED, "ronda_id" integer NOT NULL REFERENCES "CertamenTabasco_ronda" ("id") DEFERRABLE INITIALLY DEFERRED, "criterio_id" integer NOT NULL REFERENCES "CertamenTabasco_criterio" ("id") DEFERRABLE INITIALLY DEFERRED, "calificacion" integer NOT NULL ) ; COMMIT;