diff --git a/apps/api/src/database/migrations/0014_deep_meteorite.sql b/apps/api/src/database/migrations/0014_deep_meteorite.sql new file mode 100644 index 0000000..8f42fe0 --- /dev/null +++ b/apps/api/src/database/migrations/0014_deep_meteorite.sql @@ -0,0 +1,9 @@ +ALTER TABLE "training_surveys" ADD COLUMN "infrastructure_mt2" text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "has_transport" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "structure_type" text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "is_open_space" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "equipment_list" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "production_list" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "product_list" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "internal_distribution_list" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "external_distribution_list" jsonb DEFAULT '[]'::jsonb NOT NULL; \ No newline at end of file diff --git a/apps/api/src/database/migrations/0015_concerned_wild_pack.sql b/apps/api/src/database/migrations/0015_concerned_wild_pack.sql new file mode 100644 index 0000000..2780816 --- /dev/null +++ b/apps/api/src/database/migrations/0015_concerned_wild_pack.sql @@ -0,0 +1 @@ +ALTER TABLE "training_surveys" ALTER COLUMN "photo1" DROP NOT NULL; \ No newline at end of file diff --git a/apps/api/src/database/migrations/0016_silent_tag.sql b/apps/api/src/database/migrations/0016_silent_tag.sql new file mode 100644 index 0000000..7bae56a --- /dev/null +++ b/apps/api/src/database/migrations/0016_silent_tag.sql @@ -0,0 +1,36 @@ +ALTER TABLE "training_surveys" DROP CONSTRAINT "training_surveys_coor_state_states_id_fk"; +--> statement-breakpoint +ALTER TABLE "training_surveys" DROP CONSTRAINT "training_surveys_coor_municipality_municipalities_id_fk"; +--> statement-breakpoint +ALTER TABLE "training_surveys" DROP CONSTRAINT "training_surveys_coor_parish_parishes_id_fk"; +--> statement-breakpoint +ALTER TABLE "training_surveys" ALTER COLUMN "general_observations" DROP NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ALTER COLUMN "paralysis_reason" DROP NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "financial_requirement_description";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "producer_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "product_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "product_description";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "installed_capacity";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "operational_capacity";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "coor_state";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "coor_municipality";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "coor_parish";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "types_of_equipment";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "equipment_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "equipment_description";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "raw_material";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "material_type";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "raw_material_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "product_count_daily";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "product_count_weekly";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "product_count_monthly";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "prod_description_internal";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "internal_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "external_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "prod_description_external";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "country";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "city";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "men_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "women_count";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "internal_distribution_list";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "external_distribution_list"; \ No newline at end of file diff --git a/apps/api/src/database/migrations/meta/0014_snapshot.json b/apps/api/src/database/migrations/meta/0014_snapshot.json new file mode 100644 index 0000000..8ac8a7e --- /dev/null +++ b/apps/api/src/database/migrations/meta/0014_snapshot.json @@ -0,0 +1,2222 @@ +{ + "id": "7e1c9832-f445-4ff9-be0b-fda8b3fb8631", + "prevId": "83db4263-dba8-4209-bd9e-a547c3bbb7b7", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity_logs": { + "name": "activity_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activityLogs_idx": { + "name": "activityLogs_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_logs_user_id_users_id_fk": { + "name": "activity_logs_user_id_users_id_fk", + "tableFrom": "activity_logs", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.roles": { + "name": "roles", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "roles_idx": { + "name": "roles_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.sessions": { + "name": "sessions", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sessions_idx": { + "name": "sessions_idx", + "columns": [ + { + "expression": "session_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.users": { + "name": "users", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_two_factor_enabled": { + "name": "is_two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "two_factor_secret": { + "name": "two_factor_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_email_verified": { + "name": "is_email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_idx": { + "name": "users_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_state_states_id_fk": { + "name": "users_state_states_id_fk", + "tableFrom": "users", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_municipality_municipalities_id_fk": { + "name": "users_municipality_municipalities_id_fk", + "tableFrom": "users", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_parish_parishes_id_fk": { + "name": "users_parish_parishes_id_fk", + "tableFrom": "users", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + }, + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.user_role": { + "name": "user_role", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_role_idx": { + "name": "user_role_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_role_user_id_users_id_fk": { + "name": "user_role_user_id_users_id_fk", + "tableFrom": "user_role", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_role_role_id_roles_id_fk": { + "name": "user_role_role_id_roles_id_fk", + "tableFrom": "user_role", + "tableTo": "roles", + "schemaTo": "auth", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.verificationToken": { + "name": "verificationToken", + "schema": "auth", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category_type": { + "name": "category_type", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "group": { + "name": "group", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "category_typeIx0": { + "name": "category_typeIx0", + "columns": [ + { + "expression": "group", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "category_typeIx1": { + "name": "category_typeIx1", + "columns": [ + { + "expression": "description", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.localities": { + "name": "localities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parish_id": { + "name": "parish_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "localities_index_03": { + "name": "localities_index_03", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_00": { + "name": "localities_index_00", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_01": { + "name": "localities_index_01", + "columns": [ + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_02": { + "name": "localities_index_02", + "columns": [ + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "localities_state_id_states_id_fk": { + "name": "localities_state_id_states_id_fk", + "tableFrom": "localities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_municipality_id_municipalities_id_fk": { + "name": "localities_municipality_id_municipalities_id_fk", + "tableFrom": "localities", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_parish_id_parishes_id_fk": { + "name": "localities_parish_id_parishes_id_fk", + "tableFrom": "localities", + "tableTo": "parishes", + "columnsFrom": [ + "parish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "localities_name_unique": { + "name": "localities_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.municipalities": { + "name": "municipalities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "municipalities_index_00": { + "name": "municipalities_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "municipalities_state_id_states_id_fk": { + "name": "municipalities_state_id_states_id_fk", + "tableFrom": "municipalities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.parishes": { + "name": "parishes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "parishes_index_00": { + "name": "parishes_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "parishes_municipality_id_municipalities_id_fk": { + "name": "parishes_municipality_id_municipalities_id_fk", + "tableFrom": "parishes", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.states": { + "name": "states", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "states_index_00": { + "name": "states_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gallery": { + "name": "gallery", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'BORRADOR'" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_user_id_users_id_fk": { + "name": "products_user_id_users_id_fk", + "tableFrom": "products", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.answers_surveys": { + "name": "answers_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "answers_index_00": { + "name": "answers_index_00", + "columns": [ + { + "expression": "answers", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_01": { + "name": "answers_index_01", + "columns": [ + { + "expression": "survey_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_02": { + "name": "answers_index_02", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "answers_surveys_survey_id_surveys_id_fk": { + "name": "answers_surveys_survey_id_surveys_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "surveys", + "columnsFrom": [ + "survey_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "answers_surveys_user_id_users_id_fk": { + "name": "answers_surveys_user_id_users_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.surveys": { + "name": "surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_audience": { + "name": "target_audience", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "published": { + "name": "published", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "questions": { + "name": "questions", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "surveys_index_00": { + "name": "surveys_index_00", + "columns": [ + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_surveys": { + "name": "training_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "firstname": { + "name": "firstname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lastname": { + "name": "lastname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visit_date": { + "name": "visit_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "situr_code_commune": { + "name": "situr_code_commune", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "commune_name": { + "name": "commune_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_rif": { + "name": "commune_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_name": { + "name": "commune_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_cedula": { + "name": "commune_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_rif": { + "name": "commune_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_phone": { + "name": "commune_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_email": { + "name": "commune_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council": { + "name": "communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situr_code_communal_council": { + "name": "situr_code_communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "communal_council_rif": { + "name": "communal_council_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_name": { + "name": "communal_council_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_cedula": { + "name": "communal_council_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_rif": { + "name": "communal_council_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_phone": { + "name": "communal_council_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_email": { + "name": "communal_council_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "osp_google_maps_link": { + "name": "osp_google_maps_link", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "osp_name": { + "name": "osp_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_address": { + "name": "osp_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_rif": { + "name": "osp_rif", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_type": { + "name": "osp_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "productive_activity": { + "name": "productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "financial_requirement_description": { + "name": "financial_requirement_description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "current_status": { + "name": "current_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ACTIVA'" + }, + "company_constitution_year": { + "name": "company_constitution_year", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "producer_count": { + "name": "producer_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_count": { + "name": "product_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_description": { + "name": "product_description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "installed_capacity": { + "name": "installed_capacity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "operational_capacity": { + "name": "operational_capacity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_fullname": { + "name": "osp_responsible_fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_cedula": { + "name": "osp_responsible_cedula", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_rif": { + "name": "osp_responsible_rif", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_phone": { + "name": "osp_responsible_phone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_email": { + "name": "osp_responsible_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "civil_state": { + "name": "civil_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "family_burden": { + "name": "family_burden", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "number_of_children": { + "name": "number_of_children", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "general_observations": { + "name": "general_observations", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "paralysis_reason": { + "name": "paralysis_reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo1": { + "name": "photo1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo2": { + "name": "photo2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo3": { + "name": "photo3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coor_state": { + "name": "coor_state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "coor_municipality": { + "name": "coor_municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "coor_parish": { + "name": "coor_parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "coor_phone": { + "name": "coor_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "eco_sector": { + "name": "eco_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_sector": { + "name": "productive_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "central_productive_activity": { + "name": "central_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "main_productive_activity": { + "name": "main_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "types_of_equipment": { + "name": "types_of_equipment", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "equipment_count": { + "name": "equipment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "equipment_description": { + "name": "equipment_description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "raw_material": { + "name": "raw_material", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "material_type": { + "name": "material_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "raw_material_count": { + "name": "raw_material_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_count_daily": { + "name": "product_count_daily", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_count_weekly": { + "name": "product_count_weekly", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_count_monthly": { + "name": "product_count_monthly", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "prod_description_internal": { + "name": "prod_description_internal", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "internal_count": { + "name": "internal_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "external_count": { + "name": "external_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "prod_description_external": { + "name": "prod_description_external", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "men_count": { + "name": "men_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "women_count": { + "name": "women_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "infrastructure_mt2": { + "name": "infrastructure_mt2", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "has_transport": { + "name": "has_transport", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "structure_type": { + "name": "structure_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_open_space": { + "name": "is_open_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "equipment_list": { + "name": "equipment_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_list": { + "name": "production_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "product_list": { + "name": "product_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "internal_distribution_list": { + "name": "internal_distribution_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "external_distribution_list": { + "name": "external_distribution_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "training_surveys_index_00": { + "name": "training_surveys_index_00", + "columns": [ + { + "expression": "firstname", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "training_surveys_state_states_id_fk": { + "name": "training_surveys_state_states_id_fk", + "tableFrom": "training_surveys", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_municipality_municipalities_id_fk": { + "name": "training_surveys_municipality_municipalities_id_fk", + "tableFrom": "training_surveys", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_parish_parishes_id_fk": { + "name": "training_surveys_parish_parishes_id_fk", + "tableFrom": "training_surveys", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_coor_state_states_id_fk": { + "name": "training_surveys_coor_state_states_id_fk", + "tableFrom": "training_surveys", + "tableTo": "states", + "columnsFrom": [ + "coor_state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_coor_municipality_municipalities_id_fk": { + "name": "training_surveys_coor_municipality_municipalities_id_fk", + "tableFrom": "training_surveys", + "tableTo": "municipalities", + "columnsFrom": [ + "coor_municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_coor_parish_parishes_id_fk": { + "name": "training_surveys_coor_parish_parishes_id_fk", + "tableFrom": "training_surveys", + "tableTo": "parishes", + "columnsFrom": [ + "coor_parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "auth.gender": { + "name": "gender", + "schema": "auth", + "values": [ + "FEMENINO", + "MASCULINO" + ] + }, + "public.nationality": { + "name": "nationality", + "schema": "public", + "values": [ + "VENEZOLANO", + "EXTRANJERO" + ] + }, + "auth.status": { + "name": "status", + "schema": "auth", + "values": [ + "ACTIVE", + "INACTIVE" + ] + } + }, + "schemas": { + "auth": "auth" + }, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": { + "auth.user_access_view": { + "columns": { + "userId": { + "name": "userId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n SELECT\n u.id AS user_id,\n u.username,\n u.email,\n u.fullname,\n r.id AS role_id,\n r.name AS role_name\nFROM\n auth.users u\nLEFT JOIN\n auth.user_role ur ON u.id = ur.user_id \nLEFT JOIN\n auth.roles r ON ur.role_id = r.id", + "name": "user_access_view", + "schema": "auth", + "isExisting": false, + "materialized": false + }, + "public.v_product_store": { + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gallery": { + "name": "gallery", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.gallery, p.address, p.status, p.user_id, u.fullname, u.email, u.phone\n from products p\n left join auth.users as u on u.id = p.user_id", + "name": "v_product_store", + "schema": "public", + "isExisting": false, + "materialized": false + }, + "public.v_surveys": { + "columns": { + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "target_audience": { + "name": "target_audience", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "definition": "select id as survey_id, title, description, created_at, closing_date, target_audience from surveys\nwhere published = true", + "name": "v_surveys", + "schema": "public", + "isExisting": false, + "materialized": false + } + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/src/database/migrations/meta/0015_snapshot.json b/apps/api/src/database/migrations/meta/0015_snapshot.json new file mode 100644 index 0000000..860291d --- /dev/null +++ b/apps/api/src/database/migrations/meta/0015_snapshot.json @@ -0,0 +1,2222 @@ +{ + "id": "3bc74762-9199-439e-8002-b53b47597790", + "prevId": "7e1c9832-f445-4ff9-be0b-fda8b3fb8631", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity_logs": { + "name": "activity_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activityLogs_idx": { + "name": "activityLogs_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_logs_user_id_users_id_fk": { + "name": "activity_logs_user_id_users_id_fk", + "tableFrom": "activity_logs", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.roles": { + "name": "roles", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "roles_idx": { + "name": "roles_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.sessions": { + "name": "sessions", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sessions_idx": { + "name": "sessions_idx", + "columns": [ + { + "expression": "session_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.users": { + "name": "users", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_two_factor_enabled": { + "name": "is_two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "two_factor_secret": { + "name": "two_factor_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_email_verified": { + "name": "is_email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_idx": { + "name": "users_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_state_states_id_fk": { + "name": "users_state_states_id_fk", + "tableFrom": "users", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_municipality_municipalities_id_fk": { + "name": "users_municipality_municipalities_id_fk", + "tableFrom": "users", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_parish_parishes_id_fk": { + "name": "users_parish_parishes_id_fk", + "tableFrom": "users", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + }, + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.user_role": { + "name": "user_role", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_role_idx": { + "name": "user_role_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_role_user_id_users_id_fk": { + "name": "user_role_user_id_users_id_fk", + "tableFrom": "user_role", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_role_role_id_roles_id_fk": { + "name": "user_role_role_id_roles_id_fk", + "tableFrom": "user_role", + "tableTo": "roles", + "schemaTo": "auth", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.verificationToken": { + "name": "verificationToken", + "schema": "auth", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category_type": { + "name": "category_type", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "group": { + "name": "group", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "category_typeIx0": { + "name": "category_typeIx0", + "columns": [ + { + "expression": "group", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "category_typeIx1": { + "name": "category_typeIx1", + "columns": [ + { + "expression": "description", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.localities": { + "name": "localities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parish_id": { + "name": "parish_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "localities_index_03": { + "name": "localities_index_03", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_00": { + "name": "localities_index_00", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_01": { + "name": "localities_index_01", + "columns": [ + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_02": { + "name": "localities_index_02", + "columns": [ + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "localities_state_id_states_id_fk": { + "name": "localities_state_id_states_id_fk", + "tableFrom": "localities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_municipality_id_municipalities_id_fk": { + "name": "localities_municipality_id_municipalities_id_fk", + "tableFrom": "localities", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_parish_id_parishes_id_fk": { + "name": "localities_parish_id_parishes_id_fk", + "tableFrom": "localities", + "tableTo": "parishes", + "columnsFrom": [ + "parish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "localities_name_unique": { + "name": "localities_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.municipalities": { + "name": "municipalities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "municipalities_index_00": { + "name": "municipalities_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "municipalities_state_id_states_id_fk": { + "name": "municipalities_state_id_states_id_fk", + "tableFrom": "municipalities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.parishes": { + "name": "parishes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "parishes_index_00": { + "name": "parishes_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "parishes_municipality_id_municipalities_id_fk": { + "name": "parishes_municipality_id_municipalities_id_fk", + "tableFrom": "parishes", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.states": { + "name": "states", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "states_index_00": { + "name": "states_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gallery": { + "name": "gallery", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'BORRADOR'" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_user_id_users_id_fk": { + "name": "products_user_id_users_id_fk", + "tableFrom": "products", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.answers_surveys": { + "name": "answers_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "answers_index_00": { + "name": "answers_index_00", + "columns": [ + { + "expression": "answers", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_01": { + "name": "answers_index_01", + "columns": [ + { + "expression": "survey_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_02": { + "name": "answers_index_02", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "answers_surveys_survey_id_surveys_id_fk": { + "name": "answers_surveys_survey_id_surveys_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "surveys", + "columnsFrom": [ + "survey_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "answers_surveys_user_id_users_id_fk": { + "name": "answers_surveys_user_id_users_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.surveys": { + "name": "surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_audience": { + "name": "target_audience", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "published": { + "name": "published", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "questions": { + "name": "questions", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "surveys_index_00": { + "name": "surveys_index_00", + "columns": [ + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_surveys": { + "name": "training_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "firstname": { + "name": "firstname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lastname": { + "name": "lastname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visit_date": { + "name": "visit_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "situr_code_commune": { + "name": "situr_code_commune", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "commune_name": { + "name": "commune_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_rif": { + "name": "commune_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_name": { + "name": "commune_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_cedula": { + "name": "commune_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_rif": { + "name": "commune_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_phone": { + "name": "commune_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_email": { + "name": "commune_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council": { + "name": "communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situr_code_communal_council": { + "name": "situr_code_communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "communal_council_rif": { + "name": "communal_council_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_name": { + "name": "communal_council_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_cedula": { + "name": "communal_council_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_rif": { + "name": "communal_council_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_phone": { + "name": "communal_council_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_email": { + "name": "communal_council_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "osp_google_maps_link": { + "name": "osp_google_maps_link", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "osp_name": { + "name": "osp_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_address": { + "name": "osp_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_rif": { + "name": "osp_rif", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_type": { + "name": "osp_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "productive_activity": { + "name": "productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "financial_requirement_description": { + "name": "financial_requirement_description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "current_status": { + "name": "current_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ACTIVA'" + }, + "company_constitution_year": { + "name": "company_constitution_year", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "producer_count": { + "name": "producer_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_count": { + "name": "product_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_description": { + "name": "product_description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "installed_capacity": { + "name": "installed_capacity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "operational_capacity": { + "name": "operational_capacity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_fullname": { + "name": "osp_responsible_fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_cedula": { + "name": "osp_responsible_cedula", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_rif": { + "name": "osp_responsible_rif", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_phone": { + "name": "osp_responsible_phone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_email": { + "name": "osp_responsible_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "civil_state": { + "name": "civil_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "family_burden": { + "name": "family_burden", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "number_of_children": { + "name": "number_of_children", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "general_observations": { + "name": "general_observations", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "paralysis_reason": { + "name": "paralysis_reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "photo1": { + "name": "photo1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo2": { + "name": "photo2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo3": { + "name": "photo3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coor_state": { + "name": "coor_state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "coor_municipality": { + "name": "coor_municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "coor_parish": { + "name": "coor_parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "coor_phone": { + "name": "coor_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "eco_sector": { + "name": "eco_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_sector": { + "name": "productive_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "central_productive_activity": { + "name": "central_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "main_productive_activity": { + "name": "main_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "types_of_equipment": { + "name": "types_of_equipment", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "equipment_count": { + "name": "equipment_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "equipment_description": { + "name": "equipment_description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "raw_material": { + "name": "raw_material", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "material_type": { + "name": "material_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "raw_material_count": { + "name": "raw_material_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_count_daily": { + "name": "product_count_daily", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_count_weekly": { + "name": "product_count_weekly", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "product_count_monthly": { + "name": "product_count_monthly", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "prod_description_internal": { + "name": "prod_description_internal", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "internal_count": { + "name": "internal_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "external_count": { + "name": "external_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "prod_description_external": { + "name": "prod_description_external", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "country": { + "name": "country", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "men_count": { + "name": "men_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "women_count": { + "name": "women_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "infrastructure_mt2": { + "name": "infrastructure_mt2", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "has_transport": { + "name": "has_transport", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "structure_type": { + "name": "structure_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_open_space": { + "name": "is_open_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "equipment_list": { + "name": "equipment_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_list": { + "name": "production_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "product_list": { + "name": "product_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "internal_distribution_list": { + "name": "internal_distribution_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "external_distribution_list": { + "name": "external_distribution_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "training_surveys_index_00": { + "name": "training_surveys_index_00", + "columns": [ + { + "expression": "firstname", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "training_surveys_state_states_id_fk": { + "name": "training_surveys_state_states_id_fk", + "tableFrom": "training_surveys", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_municipality_municipalities_id_fk": { + "name": "training_surveys_municipality_municipalities_id_fk", + "tableFrom": "training_surveys", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_parish_parishes_id_fk": { + "name": "training_surveys_parish_parishes_id_fk", + "tableFrom": "training_surveys", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_coor_state_states_id_fk": { + "name": "training_surveys_coor_state_states_id_fk", + "tableFrom": "training_surveys", + "tableTo": "states", + "columnsFrom": [ + "coor_state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_coor_municipality_municipalities_id_fk": { + "name": "training_surveys_coor_municipality_municipalities_id_fk", + "tableFrom": "training_surveys", + "tableTo": "municipalities", + "columnsFrom": [ + "coor_municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_coor_parish_parishes_id_fk": { + "name": "training_surveys_coor_parish_parishes_id_fk", + "tableFrom": "training_surveys", + "tableTo": "parishes", + "columnsFrom": [ + "coor_parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "auth.gender": { + "name": "gender", + "schema": "auth", + "values": [ + "FEMENINO", + "MASCULINO" + ] + }, + "public.nationality": { + "name": "nationality", + "schema": "public", + "values": [ + "VENEZOLANO", + "EXTRANJERO" + ] + }, + "auth.status": { + "name": "status", + "schema": "auth", + "values": [ + "ACTIVE", + "INACTIVE" + ] + } + }, + "schemas": { + "auth": "auth" + }, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": { + "auth.user_access_view": { + "columns": { + "userId": { + "name": "userId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n SELECT\n u.id AS user_id,\n u.username,\n u.email,\n u.fullname,\n r.id AS role_id,\n r.name AS role_name\nFROM\n auth.users u\nLEFT JOIN\n auth.user_role ur ON u.id = ur.user_id \nLEFT JOIN\n auth.roles r ON ur.role_id = r.id", + "name": "user_access_view", + "schema": "auth", + "isExisting": false, + "materialized": false + }, + "public.v_product_store": { + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gallery": { + "name": "gallery", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.gallery, p.address, p.status, p.user_id, u.fullname, u.email, u.phone\n from products p\n left join auth.users as u on u.id = p.user_id", + "name": "v_product_store", + "schema": "public", + "isExisting": false, + "materialized": false + }, + "public.v_surveys": { + "columns": { + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "target_audience": { + "name": "target_audience", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "definition": "select id as survey_id, title, description, created_at, closing_date, target_audience from surveys\nwhere published = true", + "name": "v_surveys", + "schema": "public", + "isExisting": false, + "materialized": false + } + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/src/database/migrations/meta/0016_snapshot.json b/apps/api/src/database/migrations/meta/0016_snapshot.json new file mode 100644 index 0000000..5c0f968 --- /dev/null +++ b/apps/api/src/database/migrations/meta/0016_snapshot.json @@ -0,0 +1,1994 @@ +{ + "id": "69862e30-9b34-4b40-b659-d30445574001", + "prevId": "3bc74762-9199-439e-8002-b53b47597790", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity_logs": { + "name": "activity_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activityLogs_idx": { + "name": "activityLogs_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_logs_user_id_users_id_fk": { + "name": "activity_logs_user_id_users_id_fk", + "tableFrom": "activity_logs", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.roles": { + "name": "roles", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "roles_idx": { + "name": "roles_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.sessions": { + "name": "sessions", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sessions_idx": { + "name": "sessions_idx", + "columns": [ + { + "expression": "session_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.users": { + "name": "users", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_two_factor_enabled": { + "name": "is_two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "two_factor_secret": { + "name": "two_factor_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_email_verified": { + "name": "is_email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_idx": { + "name": "users_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_state_states_id_fk": { + "name": "users_state_states_id_fk", + "tableFrom": "users", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_municipality_municipalities_id_fk": { + "name": "users_municipality_municipalities_id_fk", + "tableFrom": "users", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_parish_parishes_id_fk": { + "name": "users_parish_parishes_id_fk", + "tableFrom": "users", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + }, + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.user_role": { + "name": "user_role", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_role_idx": { + "name": "user_role_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_role_user_id_users_id_fk": { + "name": "user_role_user_id_users_id_fk", + "tableFrom": "user_role", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_role_role_id_roles_id_fk": { + "name": "user_role_role_id_roles_id_fk", + "tableFrom": "user_role", + "tableTo": "roles", + "schemaTo": "auth", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.verificationToken": { + "name": "verificationToken", + "schema": "auth", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category_type": { + "name": "category_type", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "group": { + "name": "group", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "category_typeIx0": { + "name": "category_typeIx0", + "columns": [ + { + "expression": "group", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "category_typeIx1": { + "name": "category_typeIx1", + "columns": [ + { + "expression": "description", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.localities": { + "name": "localities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parish_id": { + "name": "parish_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "localities_index_03": { + "name": "localities_index_03", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_00": { + "name": "localities_index_00", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_01": { + "name": "localities_index_01", + "columns": [ + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_02": { + "name": "localities_index_02", + "columns": [ + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "localities_state_id_states_id_fk": { + "name": "localities_state_id_states_id_fk", + "tableFrom": "localities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_municipality_id_municipalities_id_fk": { + "name": "localities_municipality_id_municipalities_id_fk", + "tableFrom": "localities", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_parish_id_parishes_id_fk": { + "name": "localities_parish_id_parishes_id_fk", + "tableFrom": "localities", + "tableTo": "parishes", + "columnsFrom": [ + "parish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "localities_name_unique": { + "name": "localities_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.municipalities": { + "name": "municipalities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "municipalities_index_00": { + "name": "municipalities_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "municipalities_state_id_states_id_fk": { + "name": "municipalities_state_id_states_id_fk", + "tableFrom": "municipalities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.parishes": { + "name": "parishes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "parishes_index_00": { + "name": "parishes_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "parishes_municipality_id_municipalities_id_fk": { + "name": "parishes_municipality_id_municipalities_id_fk", + "tableFrom": "parishes", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.states": { + "name": "states", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "states_index_00": { + "name": "states_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gallery": { + "name": "gallery", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'BORRADOR'" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_user_id_users_id_fk": { + "name": "products_user_id_users_id_fk", + "tableFrom": "products", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.answers_surveys": { + "name": "answers_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "answers_index_00": { + "name": "answers_index_00", + "columns": [ + { + "expression": "answers", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_01": { + "name": "answers_index_01", + "columns": [ + { + "expression": "survey_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_02": { + "name": "answers_index_02", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "answers_surveys_survey_id_surveys_id_fk": { + "name": "answers_surveys_survey_id_surveys_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "surveys", + "columnsFrom": [ + "survey_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "answers_surveys_user_id_users_id_fk": { + "name": "answers_surveys_user_id_users_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.surveys": { + "name": "surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_audience": { + "name": "target_audience", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "published": { + "name": "published", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "questions": { + "name": "questions", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "surveys_index_00": { + "name": "surveys_index_00", + "columns": [ + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_surveys": { + "name": "training_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "firstname": { + "name": "firstname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lastname": { + "name": "lastname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visit_date": { + "name": "visit_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "coor_phone": { + "name": "coor_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "osp_type": { + "name": "osp_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "eco_sector": { + "name": "eco_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_sector": { + "name": "productive_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "central_productive_activity": { + "name": "central_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "main_productive_activity": { + "name": "main_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_activity": { + "name": "productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_rif": { + "name": "osp_rif", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_name": { + "name": "osp_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "company_constitution_year": { + "name": "company_constitution_year", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "current_status": { + "name": "current_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ACTIVA'" + }, + "infrastructure_mt2": { + "name": "infrastructure_mt2", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "has_transport": { + "name": "has_transport", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "structure_type": { + "name": "structure_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_open_space": { + "name": "is_open_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "paralysis_reason": { + "name": "paralysis_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "equipment_list": { + "name": "equipment_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_list": { + "name": "production_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "product_list": { + "name": "product_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "osp_address": { + "name": "osp_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_google_maps_link": { + "name": "osp_google_maps_link", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_name": { + "name": "commune_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "situr_code_commune": { + "name": "situr_code_commune", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "commune_rif": { + "name": "commune_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_name": { + "name": "commune_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_cedula": { + "name": "commune_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_rif": { + "name": "commune_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_phone": { + "name": "commune_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_email": { + "name": "commune_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council": { + "name": "communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situr_code_communal_council": { + "name": "situr_code_communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "communal_council_rif": { + "name": "communal_council_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_name": { + "name": "communal_council_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_cedula": { + "name": "communal_council_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_rif": { + "name": "communal_council_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_phone": { + "name": "communal_council_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_email": { + "name": "communal_council_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "osp_responsible_fullname": { + "name": "osp_responsible_fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_cedula": { + "name": "osp_responsible_cedula", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_rif": { + "name": "osp_responsible_rif", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "civil_state": { + "name": "civil_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_phone": { + "name": "osp_responsible_phone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_email": { + "name": "osp_responsible_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "family_burden": { + "name": "family_burden", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "number_of_children": { + "name": "number_of_children", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "general_observations": { + "name": "general_observations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo1": { + "name": "photo1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo2": { + "name": "photo2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo3": { + "name": "photo3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "training_surveys_index_00": { + "name": "training_surveys_index_00", + "columns": [ + { + "expression": "firstname", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "training_surveys_state_states_id_fk": { + "name": "training_surveys_state_states_id_fk", + "tableFrom": "training_surveys", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_municipality_municipalities_id_fk": { + "name": "training_surveys_municipality_municipalities_id_fk", + "tableFrom": "training_surveys", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_parish_parishes_id_fk": { + "name": "training_surveys_parish_parishes_id_fk", + "tableFrom": "training_surveys", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "auth.gender": { + "name": "gender", + "schema": "auth", + "values": [ + "FEMENINO", + "MASCULINO" + ] + }, + "public.nationality": { + "name": "nationality", + "schema": "public", + "values": [ + "VENEZOLANO", + "EXTRANJERO" + ] + }, + "auth.status": { + "name": "status", + "schema": "auth", + "values": [ + "ACTIVE", + "INACTIVE" + ] + } + }, + "schemas": { + "auth": "auth" + }, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": { + "auth.user_access_view": { + "columns": { + "userId": { + "name": "userId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n SELECT\n u.id AS user_id,\n u.username,\n u.email,\n u.fullname,\n r.id AS role_id,\n r.name AS role_name\nFROM\n auth.users u\nLEFT JOIN\n auth.user_role ur ON u.id = ur.user_id \nLEFT JOIN\n auth.roles r ON ur.role_id = r.id", + "name": "user_access_view", + "schema": "auth", + "isExisting": false, + "materialized": false + }, + "public.v_product_store": { + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gallery": { + "name": "gallery", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.gallery, p.address, p.status, p.user_id, u.fullname, u.email, u.phone\n from products p\n left join auth.users as u on u.id = p.user_id", + "name": "v_product_store", + "schema": "public", + "isExisting": false, + "materialized": false + }, + "public.v_surveys": { + "columns": { + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "target_audience": { + "name": "target_audience", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "definition": "select id as survey_id, title, description, created_at, closing_date, target_audience from surveys\nwhere published = true", + "name": "v_surveys", + "schema": "public", + "isExisting": false, + "materialized": false + } + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/src/database/migrations/meta/_journal.json b/apps/api/src/database/migrations/meta/_journal.json index 6cf7e04..72608ff 100644 --- a/apps/api/src/database/migrations/meta/_journal.json +++ b/apps/api/src/database/migrations/meta/_journal.json @@ -99,6 +99,27 @@ "when": 1769629815868, "tag": "0013_cuddly_night_nurse", "breakpoints": true + }, + { + "idx": 14, + "version": "7", + "when": 1769646908602, + "tag": "0014_deep_meteorite", + "breakpoints": true + }, + { + "idx": 15, + "version": "7", + "when": 1769648728698, + "tag": "0015_concerned_wild_pack", + "breakpoints": true + }, + { + "idx": 16, + "version": "7", + "when": 1769653021994, + "tag": "0016_silent_tag", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/api/src/database/schema/surveys.ts b/apps/api/src/database/schema/surveys.ts index 9fe8599..e6d4c5b 100644 --- a/apps/api/src/database/schema/surveys.ts +++ b/apps/api/src/database/schema/surveys.ts @@ -46,12 +46,14 @@ export const answersSurveys = t.pgTable( export const trainingSurveys = t.pgTable( 'training_surveys', { - // Datos basicos + // === 1. IDENTIFICADORES Y DATOS DE VISITA === id: t.serial('id').primaryKey(), firstname: t.text('firstname').notNull(), lastname: t.text('lastname').notNull(), visitDate: t.timestamp('visit_date').notNull(), - // ubicacion + coorPhone: t.text('coor_phone'), + + // === 2. UBICACIÓN (Claves Foráneas - Nullables) === state: t .integer('state') .references(() => states.id, { onDelete: 'set null' }), @@ -61,93 +63,89 @@ export const trainingSurveys = t.pgTable( parish: t .integer('parish') .references(() => parishes.id, { onDelete: 'set null' }), - siturCodeCommune: t.text('situr_code_commune').notNull(), + + // === 3. DATOS DE LA OSP (Organización Socioproductiva) === + ospType: t.text('osp_type').notNull(), // UPF, EPS, etc. + ecoSector: t.text('eco_sector').notNull().default(''), + productiveSector: t.text('productive_sector').notNull().default(''), + centralProductiveActivity: t + .text('central_productive_activity') + .notNull() + .default(''), + mainProductiveActivity: t + .text('main_productive_activity') + .notNull() + .default(''), + productiveActivity: t.text('productive_activity').notNull(), + ospRif: t.text('osp_rif').notNull(), + ospName: t.text('osp_name').notNull(), + companyConstitutionYear: t.integer('company_constitution_year').notNull(), + currentStatus: t.text('current_status').notNull().default('ACTIVA'), + infrastructureMt2: t.text('infrastructure_mt2').notNull().default(''), + hasTransport: t.boolean('has_transport').notNull().default(false), + structureType: t.text('structure_type').notNull().default(''), + isOpenSpace: t.boolean('is_open_space').notNull().default(false), + paralysisReason: t.text('paralysis_reason'), + equipmentList: t.jsonb('equipment_list').notNull().default([]), + productionList: t.jsonb('production_list').notNull().default([]), + productList: t.jsonb('product_list').notNull().default([]), + ospAddress: t.text('osp_address').notNull(), + ospGoogleMapsLink: t.text('osp_google_maps_link').notNull().default(''), communeName: t.text('commune_name').notNull().default(''), + siturCodeCommune: t.text('situr_code_commune').notNull(), communeRif: t.text('commune_rif').notNull().default(''), - communeSpokespersonName: t.text('commune_spokesperson_name').notNull().default(''), - communeSpokespersonCedula: t.text('commune_spokesperson_cedula').notNull().default(''), - communeSpokespersonRif: t.text('commune_spokesperson_rif').notNull().default(''), - communeSpokespersonPhone: t.text('commune_spokesperson_phone').notNull().default(''), + communeSpokespersonName: t + .text('commune_spokesperson_name') + .notNull() + .default(''), + communeSpokespersonCedula: t + .text('commune_spokesperson_cedula') + .notNull() + .default(''), + communeSpokespersonRif: t + .text('commune_spokesperson_rif') + .notNull() + .default(''), + communeSpokespersonPhone: t + .text('commune_spokesperson_phone') + .notNull() + .default(''), communeEmail: t.text('commune_email').notNull().default(''), communalCouncil: t.text('communal_council').notNull(), siturCodeCommunalCouncil: t.text('situr_code_communal_council').notNull(), communalCouncilRif: t.text('communal_council_rif').notNull().default(''), - communalCouncilSpokespersonName: t.text('communal_council_spokesperson_name').notNull().default(''), - communalCouncilSpokespersonCedula: t.text('communal_council_spokesperson_cedula').notNull().default(''), - communalCouncilSpokespersonRif: t.text('communal_council_spokesperson_rif').notNull().default(''), - communalCouncilSpokespersonPhone: t.text('communal_council_spokesperson_phone').notNull().default(''), - communalCouncilEmail: t.text('communal_council_email').notNull().default(''), - ospGoogleMapsLink: t.text('osp_google_maps_link').notNull().default(''), - // datos del OSP (ORGANIZACIÓN SOCIOPRODUCTIVA) - ospName: t.text('osp_name').notNull(), - ospAddress: t.text('osp_address').notNull(), - ospRif: t.text('osp_rif').notNull(), - ospType: t.text('osp_type').notNull(), - productiveActivity: t.text('productive_activity').notNull(), - financialRequirementDescription: t - .text('financial_requirement_description') + communalCouncilSpokespersonName: t + .text('communal_council_spokesperson_name') + .notNull() + .default(''), + communalCouncilSpokespersonCedula: t + .text('communal_council_spokesperson_cedula') + .notNull() + .default(''), + communalCouncilSpokespersonRif: t + .text('communal_council_spokesperson_rif') + .notNull() + .default(''), + communalCouncilSpokespersonPhone: t + .text('communal_council_spokesperson_phone') + .notNull() + .default(''), + communalCouncilEmail: t + .text('communal_council_email') .notNull() .default(''), - currentStatus: t.text('current_status').notNull().default('ACTIVA'), - companyConstitutionYear: t.integer('company_constitution_year').notNull(), - producerCount: t.integer('producer_count').notNull(), - productCount: t.integer('product_count').notNull().default(0), - productDescription: t.text('product_description').notNull(), - installedCapacity: t.text('installed_capacity').notNull(), - operationalCapacity: t.text('operational_capacity').notNull(), - // datos del responsable ospResponsibleFullname: t.text('osp_responsible_fullname').notNull(), ospResponsibleCedula: t.text('osp_responsible_cedula').notNull(), ospResponsibleRif: t.text('osp_responsible_rif').notNull(), + civilState: t.text('civil_state').notNull(), ospResponsiblePhone: t.text('osp_responsible_phone').notNull(), ospResponsibleEmail: t.text('osp_responsible_email').notNull(), - civilState: t.text('civil_state').notNull(), familyBurden: t.integer('family_burden').notNull(), numberOfChildren: t.integer('number_of_children').notNull(), - // datos adicionales - generalObservations: t.text('general_observations').notNull(), - paralysisReason: t.text('paralysis_reason').notNull(), - // fotos - photo1: t.text('photo1').notNull(), + generalObservations: t.text('general_observations'), + photo1: t.text('photo1'), photo2: t.text('photo2'), photo3: t.text('photo3'), - // nuevos campos coordinacion - coorState: t - .integer('coor_state') - .references(() => states.id, { onDelete: 'set null' }), - coorMunicipality: t - .integer('coor_municipality') - .references(() => municipalities.id, { onDelete: 'set null' }), - coorParish: t - .integer('coor_parish') - .references(() => parishes.id, { onDelete: 'set null' }), - coorPhone: t.text('coor_phone'), - // sectores - ecoSector: t.text('eco_sector').notNull().default(''), - productiveSector: t.text('productive_sector').notNull().default(''), - centralProductiveActivity: t.text('central_productive_activity').notNull().default(''), - mainProductiveActivity: t.text('main_productive_activity').notNull().default(''), - // equipamiento - typesOfEquipment: t.text('types_of_equipment').notNull().default(''), - equipmentCount: t.integer('equipment_count').notNull().default(0), - equipmentDescription: t.text('equipment_description').notNull().default(''), - // materia prima - rawMaterial: t.text('raw_material').notNull().default(''), - materialType: t.text('material_type').notNull().default(''), - rawMaterialCount: t.integer('raw_material_count').notNull().default(0), - // conteo de productos - productCountDaily: t.integer('product_count_daily').notNull().default(0), - productCountWeekly: t.integer('product_count_weekly').notNull().default(0), - productCountMonthly: t.integer('product_count_monthly').notNull().default(0), - // nuevos campos adicionales - prodDescriptionInternal: t.text('prod_description_internal').notNull().default(''), - internalCount: t.integer('internal_count').notNull().default(0), - externalCount: t.integer('external_count').notNull().default(0), - prodDescriptionExternal: t.text('prod_description_external').notNull().default(''), - country: t.text('country').notNull().default(''), - city: t.text('city').notNull().default(''), - menCount: t.integer('men_count').notNull().default(0), - womenCount: t.integer('women_count').notNull().default(0), ...timestamps, }, (trainingSurveys) => ({ diff --git a/apps/api/src/features/training/dto/create-training.dto.ts b/apps/api/src/features/training/dto/create-training.dto.ts index 3c491b1..375634e 100644 --- a/apps/api/src/features/training/dto/create-training.dto.ts +++ b/apps/api/src/features/training/dto/create-training.dto.ts @@ -1,7 +1,16 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsDateString, IsInt, IsOptional, IsString } from 'class-validator'; +import { Transform, Type } from 'class-transformer'; +import { + IsArray, + IsBoolean, + IsDateString, + IsInt, + IsOptional, + IsString, +} from 'class-validator'; export class CreateTrainingDto { + // === 1. DATOS BÁSICOS === @ApiProperty() @IsString() firstname: string; @@ -12,7 +21,25 @@ export class CreateTrainingDto { @ApiProperty() @IsDateString() - visitDate: string; + visitDate: string; // Llega como string ISO "2024-11-11T10:00" + + @ApiProperty() + @IsString() + @IsOptional() + coorPhone?: string; + + // === 2. DATOS OSP === + @ApiProperty() + @IsString() + ospName: string; + + @ApiProperty() + @IsString() + ospRif: string; + + @ApiProperty() + @IsString() + ospType: string; // 'UPF', etc. @ApiProperty() @IsString() @@ -20,24 +47,108 @@ export class CreateTrainingDto { @ApiProperty() @IsString() - @IsOptional() - financialRequirementDescription?: string; + currentStatus: string; @ApiProperty() @IsInt() + @Type(() => Number) // Convierte "2017" -> 2017 + companyConstitutionYear: number; + + @ApiProperty() + @IsString() @IsOptional() - state: number; + ospAddress: string; + + @ApiProperty() + @IsString() + @IsOptional() + ospGoogleMapsLink?: string; + + @ApiProperty() + @IsString() + @IsOptional() + infrastructureMt2?: string; + + @ApiProperty() + @IsString() + @IsOptional() + structureType?: string; + + @ApiProperty() + @IsBoolean() + @IsOptional() + @Transform(({ value }) => value === 'true' || value === true) // Convierte "false" -> false + hasTransport?: boolean; + + @ApiProperty() + @IsBoolean() + @IsOptional() + @Transform(({ value }) => value === 'true' || value === true) + isOpenSpace?: boolean; + + @ApiProperty() + @IsString() + @IsOptional() + paralysisReason?: string; + + @ApiProperty() + @IsString() + @IsOptional() + generalObservations?: string; + + // === 3. SECTORES === + @ApiProperty() + @IsString() + ecoSector: string; + + @ApiProperty() + @IsString() + productiveSector: string; + + @ApiProperty() + @IsString() + centralProductiveActivity: string; + + @ApiProperty() + @IsString() + mainProductiveActivity: string; + + // === 4. DATOS RESPONSABLE === + @ApiProperty() + @IsString() + ospResponsibleFullname: string; + + @ApiProperty() + @IsString() + ospResponsibleCedula: string; + + @ApiProperty() + @IsString() + ospResponsibleRif: string; + + @ApiProperty() + @IsString() + ospResponsiblePhone: string; + + @ApiProperty() + @IsString() + ospResponsibleEmail: string; + + @ApiProperty() + @IsString() + civilState: string; @ApiProperty() @IsInt() - @IsOptional() - municipality: number; + @Type(() => Number) // Convierte "3" -> 3 + familyBurden: number; @ApiProperty() @IsInt() - @IsOptional() - parish: number; + @Type(() => Number) + numberOfChildren: number; + // === 5. COMUNA Y CONSEJO COMUNAL === @ApiProperty() @IsString() siturCodeCommune: string; @@ -102,217 +213,51 @@ export class CreateTrainingDto { @IsString() communalCouncilEmail: string; - @ApiProperty() - @IsString() - ospGoogleMapsLink: string; + // === 6. LISTAS (Arrays JSON) === + // Reciben un string JSON '[{...}]' y lo convierten a Objeto JS real @ApiProperty() - @IsString() - ospName: string; - - @ApiProperty() - @IsString() - ospAddress: string; - - @ApiProperty() - @IsString() - ospRif: string; - - @ApiProperty() - @IsString() - ospType: string; - - @ApiProperty() - @IsString() - currentStatus: string; - - @ApiProperty() - @IsInt() - companyConstitutionYear: number; - - @ApiProperty() - @IsInt() - producerCount: number; - - @ApiProperty() - @IsInt() @IsOptional() - productCount: number; + @IsArray() + @Transform(({ value }) => { + if (typeof value === 'string') { + try { + return JSON.parse(value); + } catch { + return []; + } + } + return value; + }) + equipmentList?: any[]; @ApiProperty() - @IsString() - productDescription: string; - - @ApiProperty() - @IsString() - installedCapacity: string; - - @ApiProperty() - @IsString() - operationalCapacity: string; - - @ApiProperty() - @IsString() - ospResponsibleFullname: string; - - @ApiProperty() - @IsString() - ospResponsibleCedula: string; - - @ApiProperty() - @IsString() - ospResponsibleRif: string; - - @ApiProperty() - @IsString() - ospResponsiblePhone: string; - - @ApiProperty() - @IsString() - ospResponsibleEmail: string; - - @ApiProperty() - @IsString() - civilState: string; - - @ApiProperty() - @IsInt() - familyBurden: number; - - @ApiProperty() - @IsInt() - numberOfChildren: number; - - @ApiProperty() - @IsString() - generalObservations: string; - - @ApiProperty() - @IsString() @IsOptional() - photo1?: string; + @IsArray() + @Transform(({ value }) => { + if (typeof value === 'string') { + try { + return JSON.parse(value); + } catch { + return []; + } + } + return value; + }) + productionList?: any[]; @ApiProperty() - @IsString() @IsOptional() - photo2?: string; - - @ApiProperty() - @IsString() - @IsOptional() - photo3?: string; - - @ApiProperty() - @IsString() - @IsOptional() - paralysisReason: string; - - // nuevos campos coordinacion - @ApiProperty() - @IsInt() - @IsOptional() - coorState?: number; - - @ApiProperty() - @IsInt() - @IsOptional() - coorMunicipality?: number; - - @ApiProperty() - @IsInt() - @IsOptional() - coorParish?: number; - - @ApiProperty() - @IsString() - @IsOptional() - coorPhone?: string; - - // sectores - @ApiProperty() - @IsString() - ecoSector: string; - - @ApiProperty() - @IsString() - productiveSector: string; - - @ApiProperty() - @IsString() - centralProductiveActivity: string; - - @ApiProperty() - @IsString() - mainProductiveActivity: string; - - // equipamiento - @ApiProperty() - @IsString() - typesOfEquipment: string; - - @ApiProperty() - @IsInt() - equipmentCount: number; - - @ApiProperty() - @IsString() - equipmentDescription: string; - - // materia prima - @ApiProperty() - @IsString() - rawMaterial: string; - - @ApiProperty() - @IsString() - materialType: string; - - @ApiProperty() - @IsInt() - rawMaterialCount: number; - - // conteo de productos - @ApiProperty() - @IsInt() - productCountDaily: number; - - @ApiProperty() - @IsInt() - productCountWeekly: number; - - @ApiProperty() - @IsInt() - productCountMonthly: number; - - @ApiProperty() - @IsString() - prodDescriptionInternal: string; - - @ApiProperty() - @IsInt() - internalCount: number; - - @ApiProperty() - @IsInt() - externalCount: number; - - @ApiProperty() - @IsString() - prodDescriptionExternal: string; - - @ApiProperty() - @IsString() - country: string; - - @ApiProperty() - @IsString() - city: string; - - @ApiProperty() - @IsInt() - menCount: number; - - @ApiProperty() - @IsInt() - womenCount: number; + @IsArray() + @Transform(({ value }) => { + if (typeof value === 'string') { + try { + return JSON.parse(value); + } catch { + return []; + } + } + return value; + }) + productList?: any[]; } diff --git a/apps/api/src/features/training/training.service.ts b/apps/api/src/features/training/training.service.ts index cf4ee10..6b4528d 100644 --- a/apps/api/src/features/training/training.service.ts +++ b/apps/api/src/features/training/training.service.ts @@ -74,95 +74,121 @@ export class TrainingService { const filters: SQL[] = []; - if (startDate) { + if (startDate) filters.push(gte(trainingSurveys.visitDate, new Date(startDate))); - } - - if (endDate) { + if (endDate) filters.push(lte(trainingSurveys.visitDate, new Date(endDate))); - } - - if (stateId) { - filters.push(eq(trainingSurveys.state, stateId)); - } - - if (municipalityId) { + if (stateId) filters.push(eq(trainingSurveys.state, stateId)); + if (municipalityId) filters.push(eq(trainingSurveys.municipality, municipalityId)); - } - - if (parishId) { - filters.push(eq(trainingSurveys.parish, parishId)); - } - - if (ospType) { - filters.push(eq(trainingSurveys.ospType, ospType)); - } + if (parishId) filters.push(eq(trainingSurveys.parish, parishId)); + if (ospType) filters.push(eq(trainingSurveys.ospType, ospType)); const whereCondition = filters.length > 0 ? and(...filters) : undefined; - const totalOspsResult = await this.drizzle - .select({ count: sql`count(*)` }) - .from(trainingSurveys) - .where(whereCondition); - const totalOsps = Number(totalOspsResult[0].count); + // Ejecutamos todas las consultas en paralelo con Promise.all para mayor velocidad + const [ + totalOspsResult, + totalProducersResult, + totalProductsResult, // Nuevo: Calculado desde el JSON + statusDistribution, + activityDistribution, + typeDistribution, + stateDistribution, + yearDistribution, + ] = await Promise.all([ + // 1. Total OSPs + this.drizzle + .select({ count: sql`count(*)` }) + .from(trainingSurveys) + .where(whereCondition), - const totalProducersResult = await this.drizzle - .select({ sum: sql`sum(${trainingSurveys.producerCount})` }) - .from(trainingSurveys) - .where(whereCondition); - const totalProducers = Number(totalProducersResult[0].sum || 0); + // 2. Total Productores (Columna plana que mantuviste) + this.drizzle + .select({ + sum: sql` + SUM( + ( + SELECT SUM( + COALESCE((item->>'menCount')::int, 0) + + COALESCE((item->>'womenCount')::int, 0) + ) + FROM jsonb_array_elements(${trainingSurveys.productList}) as item + ) + ) + `, + }) + .from(trainingSurveys) + .where(whereCondition), - const statusDistribution = await this.drizzle - .select({ - name: trainingSurveys.currentStatus, - value: sql`count(*)`, - }) - .from(trainingSurveys) - .where(whereCondition) - .groupBy(trainingSurveys.currentStatus); + // 3. NUEVO: Total Productos (Contamos el largo del array JSON productList) + this.drizzle + .select({ + sum: sql`sum(jsonb_array_length(${trainingSurveys.productList}))`, + }) + .from(trainingSurveys) + .where(whereCondition), - const activityDistribution = await this.drizzle - .select({ - name: trainingSurveys.productiveActivity, - value: sql`count(*)`, - }) - .from(trainingSurveys) - .where(whereCondition) - .groupBy(trainingSurveys.productiveActivity); + // 4. Distribución por Estatus + this.drizzle + .select({ + name: trainingSurveys.currentStatus, + value: sql`count(*)`, + }) + .from(trainingSurveys) + .where(whereCondition) + .groupBy(trainingSurveys.currentStatus), - const typeDistribution = await this.drizzle - .select({ - name: trainingSurveys.ospType, - value: sql`count(*)`, - }) - .from(trainingSurveys) - .where(whereCondition) - .groupBy(trainingSurveys.ospType); + // 5. Distribución por Actividad + this.drizzle + .select({ + name: trainingSurveys.productiveActivity, + value: sql`count(*)`, + }) + .from(trainingSurveys) + .where(whereCondition) + .groupBy(trainingSurveys.productiveActivity), - // New Aggregations - const stateDistribution = await this.drizzle - .select({ - name: states.name, - value: sql`count(${trainingSurveys.id})`, - }) - .from(trainingSurveys) - .leftJoin(states, eq(trainingSurveys.state, states.id)) - .where(whereCondition) - .groupBy(states.name); + // 6. Distribución por Tipo + this.drizzle + .select({ + name: trainingSurveys.ospType, + value: sql`count(*)`, + }) + .from(trainingSurveys) + .where(whereCondition) + .groupBy(trainingSurveys.ospType), - const yearDistribution = await this.drizzle - .select({ - name: sql`cast(${trainingSurveys.companyConstitutionYear} as text)`, - value: sql`count(*)`, - }) - .from(trainingSurveys) - .where(whereCondition) - .groupBy(trainingSurveys.companyConstitutionYear) - .orderBy(trainingSurveys.companyConstitutionYear); + // 7. Distribución por Estado (CORREGIDO con COALESCE) + this.drizzle + .select({ + // Si states.name es NULL, devuelve 'Sin Asignar' + name: sql`COALESCE(${states.name}, 'Sin Asignar')`, + value: sql`count(${trainingSurveys.id})`, + }) + .from(trainingSurveys) + .leftJoin(states, eq(trainingSurveys.state, states.id)) + .where(whereCondition) + // Importante: Agrupar también por el resultado del COALESCE o por states.name + .groupBy(states.name), + + // 8. Distribución por Año + this.drizzle + .select({ + name: sql`cast(${trainingSurveys.companyConstitutionYear} as text)`, + value: sql`count(*)`, + }) + .from(trainingSurveys) + .where(whereCondition) + .groupBy(trainingSurveys.companyConstitutionYear) + .orderBy(trainingSurveys.companyConstitutionYear), + ]); return { - totalOsps, - totalProducers, + totalOsps: Number(totalOspsResult[0]?.count || 0), + totalProducers: Number(totalProducersResult[0]?.sum || 0), + totalProducts: Number(totalProductsResult[0]?.sum || 0), // Dato extraído del JSON + statusDistribution: statusDistribution.map((item) => ({ ...item, value: Number(item.value), @@ -239,16 +265,30 @@ export class TrainingService { createTrainingDto: CreateTrainingDto, files: Express.Multer.File[], ) { + // 1. Guardar fotos const photoPaths = await this.saveFiles(files); + // 2. Extraer solo visitDate para formatearlo. + // Ya NO extraemos state, municipality, etc. porque no vienen en el DTO. + const { visitDate, ...rest } = createTrainingDto; + const [newRecord] = await this.drizzle .insert(trainingSurveys) .values({ - ...createTrainingDto, - visitDate: new Date(createTrainingDto.visitDate), - photo1: photoPaths[0] || '', - photo2: photoPaths[1] || null, - photo3: photoPaths[2] || null, + // Insertamos el resto de datos planos y las listas (arrays) + ...rest, + + // Conversión de fecha + visitDate: new Date(visitDate), + + // 3. Asignar fotos de forma segura + photo1: photoPaths[0] ?? null, + photo2: photoPaths[1] ?? null, + photo3: photoPaths[2] ?? null, + + // NOTA: Como las columnas state, municipality, etc. en la BD + // tienen "onDelete: set null" o son nullables, al no pasarlas aquí, + // Postgres automáticamente las guardará como NULL. }) .returning(); diff --git a/apps/web/.env_template b/apps/web/.env_template index 9450d76..9f3158c 100644 --- a/apps/web/.env_template +++ b/apps/web/.env_template @@ -1,4 +1,5 @@ AUTH_URL = http://localhost:3000 AUTH_SECRET=wWgIwkHIGr28ydIUPsgVGNUNxXQ+brg1XXtA8PfjJjAEPJLDP2UTghWL8aE= API_URL=http://localhost:8000 +NEXT_PUBLIC_API_URL=http://localhost:8000 diff --git a/apps/web/constants/routes.ts b/apps/web/constants/routes.ts index 619533c..0dfd87e 100644 --- a/apps/web/constants/routes.ts +++ b/apps/web/constants/routes.ts @@ -10,14 +10,14 @@ export const GeneralItems: NavItem[] = [ isActive: false, items: [], // No child items }, - { - title: 'ProduTienda', - url: '/dashboard/productos/', - icon: 'blocks', - shortcut: ['p', 'p'], - isActive: false, - items: [], // No child items - }, + // { + // title: 'ProduTienda', + // url: '/dashboard/productos/', + // icon: 'blocks', + // shortcut: ['p', 'p'], + // isActive: false, + // items: [], // No child items + // }, ]; export const AdministrationItems: NavItem[] = [ @@ -78,7 +78,7 @@ export const StatisticsItems: NavItem[] = [ role: ['admin', 'superadmin', 'autoridad'], }, { - title: 'OSP', + title: 'Datos OSP', shortcut: ['s', 's'], url: '/dashboard/estadisticas/socioproductiva', icon: 'blocks', diff --git a/apps/web/feactures/training/actions/training-actions.ts b/apps/web/feactures/training/actions/training-actions.ts index e73806a..b96b3a4 100644 --- a/apps/web/feactures/training/actions/training-actions.ts +++ b/apps/web/feactures/training/actions/training-actions.ts @@ -90,6 +90,8 @@ export const createTrainingAction = async ( payloadToSend = rest as any; } + console.log(payloadToSend); + const [error, data] = await safeFetchApi( TrainingMutate, '/training', diff --git a/apps/web/feactures/training/components/equipment-list.tsx b/apps/web/feactures/training/components/equipment-list.tsx new file mode 100644 index 0000000..7a2e4a7 --- /dev/null +++ b/apps/web/feactures/training/components/equipment-list.tsx @@ -0,0 +1,171 @@ +import { Button } from '@repo/shadcn/button'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@repo/shadcn/components/ui/dialog'; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from '@repo/shadcn/components/ui/table'; +import { Input } from '@repo/shadcn/input'; +import { Label } from '@repo/shadcn/label'; +import { Trash2 } from 'lucide-react'; +import { useState } from 'react'; +import { useFieldArray, useFormContext } from 'react-hook-form'; + +export function EquipmentList() { + const { control, register } = useFormContext(); + const { fields, append, remove } = useFieldArray({ + control, + name: 'equipmentList', + }); + const [isOpen, setIsOpen] = useState(false); + const [newItem, setNewItem] = useState({ + machine: '', + specifications: '', + quantity: '', + }); + + const handleAdd = () => { + if (newItem.machine && newItem.quantity) { + append({ ...newItem, quantity: Number(newItem.quantity) }); + setNewItem({ machine: '', specifications: '', quantity: '' }); + setIsOpen(false); + } + }; + + return ( +
+
+

Datos del Equipamiento

+ + + + + + + Agregar Maquinaria/Equipo + + + Datos de equipamiento + +
+
+ + + setNewItem({ ...newItem, machine: e.target.value }) + } + placeholder="Nombre de la maquinaria" + /> +
+
+ + + setNewItem({ ...newItem, specifications: e.target.value }) + } + placeholder="Especificaciones técnicas" + /> +
+
+ + + setNewItem({ ...newItem, quantity: e.target.value }) + } + placeholder="0" + /> +
+
+ + + +
+
+
+
+
+ +
+ + + + Maquinaria + Especificaciones + Cantidad + + + + + {fields.map((field, index) => ( + + + + {/* @ts-ignore */} + {field.machine} + + + + {/* @ts-ignore */} + {field.specifications} + + + + {/* @ts-ignore */} + {field.quantity} + + + + + + ))} + {fields.length === 0 && ( + + + No hay equipamiento registrado + + + )} + +
+
+
+ ); +} diff --git a/apps/web/feactures/training/components/form.tsx b/apps/web/feactures/training/components/form.tsx index 0488bf9..a3b34be 100644 --- a/apps/web/feactures/training/components/form.tsx +++ b/apps/web/feactures/training/components/form.tsx @@ -19,9 +19,19 @@ import { SelectValue, } from '@repo/shadcn/select'; import { Textarea } from '@repo/shadcn/textarea'; -import { useForm } from 'react-hook-form'; +import { useForm, useWatch } from 'react-hook-form'; +import { + ACTIVIDAD_CENTRAL_MAP, + ACTIVIDAD_PRINCIPAL_MAP, + ACTIVIDAD_PRODUCTIVA_MAP, + SECTOR_ECONOMICO_OPTIONS, + SECTOR_PRODUCTIVO_MAP, +} from '../constants/osp-data'; import { useCreateTraining, useUpdateTraining } from '../hooks/use-training'; import { TrainingSchema, trainingSchema } from '../schemas/training'; +import { EquipmentList } from './equipment-list'; +import { ProductActivityList } from './product-activity-list'; +import { ProductionList } from './production-list'; import { useMunicipalityQuery, @@ -34,114 +44,8 @@ import { CardHeader, CardTitle, } from '@repo/shadcn/components/ui/card'; -import { SelectSearchable } from '@repo/shadcn/select-searchable'; import React from 'react'; -import { COUNTRY_OPTIONS } from '@/constants/countries'; - -// const PRODUCTIVE_ACTIVITIES = [ -// 'Agricola', -// 'Textil', -// 'Bloquera', -// 'Carpinteria', -// 'Unidad de suministro', -// ]; - -const ECO_SECTORS = ['Primario', 'Secundario', 'Terciario']; - -const PRODUCTIVE_SECTORS = ['Agricola', 'Manufactura', 'Servicios', 'Comercio', 'Turismo']; - -const CENTRAL_PRODUCTIVE_ACTIVITY = [ - 'Produción Vegetal', - 'Produción Animal', - 'Produción Animal y Vegetal', - 'INDUSTRIAL', - 'SERVICIOS', - 'TURISMO', - 'COMERCIO' -]; - -const MAIN_PRODUCTIVE_ACTIVITY = [ - 'AGRICULTURA ', - 'CRIA ', - 'PATIOS PRODUCTIVOS O CONUCOS ', - 'TRANSFORMACION DE LA MATERIA PRIMA', - 'TALLER DE COFECCION TEXTIL ', - 'CONSTRUCION ', - 'OFRECER PRODUCTOS DE BIENES Y SERVICIOS', - 'VISITAS GUIADAS ', - 'ALOJAMIENTO ', - 'TURISMO', - 'COMERCIO' -]; - -const PRODUCTIVE_ACTIVITIES = [ - 'SIEMBRA DE MAIZ ', - 'SIEMBRA DE AJI', - 'SIEMBRA DE CAFÉ ', - 'SIEMBRA DE PLATANO', - 'SIEMBRA DE CAMBUR ', - 'SIEMBRA DE AGUACATE', - 'SIEMBRA DE FRUTAS', - 'SIEMBRA DE HORTALIZAS ', - 'SIEMBRA DE TOMATE ', - 'SIEMBRA DE CACAO', - 'SIEMBRA DE PIMENTON ', - 'SIEMBRA DE YUCA ', - 'SIEMBRA DE CAÑA DE AZUCAR ', - 'SIEMBRA DE GRANOS (CARAOTAS, FRIJOLES)', - 'SIEMBRA DE ARROZ', - 'SIEMBRA DE CEREALES (CEBADA, LINAZA, SOYA)', - 'ELABORACION DE BIO-INSUMO (ABONO ORGANICO) ', - 'BOVINO ', - 'PORCINO', - 'CAPRINO', - 'CUNICULTURA', - 'AVICOLA', - 'PISCICULA', - 'SIEMBRA Y CRIA ', - 'ELABORACION DE PRODUCTOS QUIMICOS (LIMPIEZA E HIGIENE PERSONAL)', - 'PANADERIAS', - 'RESPOSTERIA ', - 'ELABORACION DE HARINAS PRECOCIDA ', - 'PLANTA ABA (ELABORACION DE ALIMENTOS BALANCEADOS PARA ANIMALES)', - 'ELABORACION DE PRODUCTOS DERIVADO DE LA LECHE (VACA, CABRA, BUFFALA)', - 'EMPAQUETADORAS DE GRANOS Y POLVOS ', - 'ELABORACION DE ACEITE COMESTIBLE ', - 'FABRICA DE HIELO', - 'ELABORACION DE PAPELON', - 'ARTESANIAS', - 'ELABORACION DE UNIFORME ESCOLARES Y PRENDA DE VESTIR ', - 'ELABORACION DE PRENDAS INTIMAS ', - 'ELABORACION DE LENCERIA ', - 'SUBLIMACION DE TEJIDOS ', - 'ELABORACION DE CALZADOS ', - 'BLOQUERAS ', - 'PLANTA PREMEZCLADORA DE CEMENTO', - 'CARPINTERIAS', - 'HERRERIAS', - 'MERCADOS COMUNALES', - 'CENTROS DE ACOPIOS Y DISTRIBUCION', - 'UNIDAD DE SUMINISTRO', - 'MATADERO (SALA DE MATANZA DE ANIMALES)', - 'PELUQUERIA', - 'BARBERIA', - 'AGENCIAS DE FESTEJOS', - 'LAVANDERIAS', - 'REPARACION DE CALZADOS', - 'TALLER DE MECANICA', - 'TRANSPORTES', - 'RUTAS TURISTICAS', - 'POSADAS', - 'HOTELES', - 'AGENCIAS DE VIAJES', - 'VENTA DE VIVERES', - 'VENTAS DE PRENDAS DE VESTIR', - 'VENTA DE PRODUCTOS QUIMICOS Y DERIVADOS', - 'BODEGAS COMUNALES', - 'FRIGORIFICOS Y CARNICOS' -] - const OSP_TYPES = ['EPSIC', 'EPSDC', 'UPF', 'OTROS', 'COOPERATIVA']; const STATUS_OPTIONS = ['ACTIVA', 'INACTIVA']; const CIVIL_STATE_OPTIONS = ['Soltero', 'Casado']; @@ -169,7 +73,8 @@ export function CreateTrainingForm({ const [coorState, setcoorState] = React.useState(0); const [coorMunicipality, setcoorMunicipality] = React.useState(0); - const [disabledCoorMunicipality, setDisabledCoorMunicipality] = React.useState(true); + const [disabledCoorMunicipality, setDisabledCoorMunicipality] = + React.useState(true); const [disabledCoorParish, setDisabledCoorParish] = React.useState(true); const [selectedFiles, setSelectedFiles] = React.useState([]); @@ -178,15 +83,136 @@ export function CreateTrainingForm({ const { data: dataMunicipality } = useMunicipalityQuery(state); const { data: dataParish } = useParishQuery(municipality); + const formatToLocalISO = (dateStr?: string | Date) => { + const date = dateStr ? new Date(dateStr) : new Date(); + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + const hours = String(date.getHours()).padStart(2, '0'); + const minutes = String(date.getMinutes()).padStart(2, '0'); + return `${year}-${month}-${day}T${hours}:${minutes}`; + }; + + const form = useForm({ + resolver: zodResolver(trainingSchema), + defaultValues: { + firstname: defaultValues?.firstname || '', + lastname: defaultValues?.lastname || '', + coorState: defaultValues?.coorState || undefined, + coorMunicipality: defaultValues?.coorMunicipality || undefined, + coorParish: defaultValues?.coorParish || undefined, + coorPhone: defaultValues?.coorPhone || '', + visitDate: formatToLocalISO(defaultValues?.visitDate), + productiveActivity: defaultValues?.productiveActivity || '', + ecoSector: defaultValues?.ecoSector || undefined, + productiveSector: defaultValues?.productiveSector || undefined, + centralProductiveActivity: defaultValues?.centralProductiveActivity || '', + mainProductiveActivity: defaultValues?.mainProductiveActivity || '', + + photo1: defaultValues?.photo1 || '', + photo2: defaultValues?.photo2 || '', + photo3: defaultValues?.photo3 || '', + + siturCodeCommune: defaultValues?.siturCodeCommune || '', + communeName: defaultValues?.communeName || '', + communeRif: defaultValues?.communeRif || '', + communeSpokespersonName: defaultValues?.communeSpokespersonName || '', + communeSpokespersonCedula: defaultValues?.communeSpokespersonCedula || '', + communeSpokespersonRif: defaultValues?.communeSpokespersonRif || '', + communeSpokespersonPhone: defaultValues?.communeSpokespersonPhone || '', + communeEmail: defaultValues?.communeEmail || '', + communalCouncil: defaultValues?.communalCouncil || '', + siturCodeCommunalCouncil: defaultValues?.siturCodeCommunalCouncil || '', + communalCouncilRif: defaultValues?.communalCouncilRif || '', + communalCouncilSpokespersonName: + defaultValues?.communalCouncilSpokespersonName || '', + communalCouncilSpokespersonCedula: + defaultValues?.communalCouncilSpokespersonCedula || '', + communalCouncilSpokespersonRif: + defaultValues?.communalCouncilSpokespersonRif || '', + communalCouncilSpokespersonPhone: + defaultValues?.communalCouncilSpokespersonPhone || '', + communalCouncilEmail: defaultValues?.communalCouncilEmail || '', + ospGoogleMapsLink: defaultValues?.ospGoogleMapsLink || '', + ospName: defaultValues?.ospName || '', + ospAddress: defaultValues?.ospAddress || '', + ospRif: defaultValues?.ospRif || '', + ospType: defaultValues?.ospType || '', + currentStatus: defaultValues?.currentStatus || 'ACTIVA', + companyConstitutionYear: + defaultValues?.companyConstitutionYear || new Date().getFullYear(), + ospResponsibleFullname: defaultValues?.ospResponsibleFullname || '', + ospResponsibleCedula: defaultValues?.ospResponsibleCedula || '', + ospResponsibleRif: defaultValues?.ospResponsibleRif || '', + ospResponsiblePhone: defaultValues?.ospResponsiblePhone || '', + civilState: defaultValues?.civilState || '', + familyBurden: defaultValues?.familyBurden || 0, + numberOfChildren: defaultValues?.numberOfChildren || 0, + generalObservations: defaultValues?.generalObservations || '', + ospResponsibleEmail: defaultValues?.ospResponsibleEmail || '', + paralysisReason: defaultValues?.paralysisReason || '', + infrastructureMt2: defaultValues?.infrastructureMt2 || '', + hasTransport: defaultValues?.hasTransport || false, + structureType: defaultValues?.structureType || '', + isOpenSpace: defaultValues?.isOpenSpace || false, + equipmentList: defaultValues?.equipmentList || [], + productionList: defaultValues?.productionList || [], + productList: defaultValues?.productList || [], + }, + mode: 'onChange', + }); + + // Cascading Select Logic + const ecoSector = useWatch({ control: form.control, name: 'ecoSector' }); + const productiveSector = useWatch({ + control: form.control, + name: 'productiveSector', + }); + const centralProductiveActivity = useWatch({ + control: form.control, + name: 'centralProductiveActivity', + }); + const mainProductiveActivity = useWatch({ + control: form.control, + name: 'mainProductiveActivity', + }); + + const productiveSectorOptions = ecoSector + ? SECTOR_PRODUCTIVO_MAP[ecoSector] || [] + : []; + const centralProductiveActivityOptions = productiveSector + ? ACTIVIDAD_CENTRAL_MAP[productiveSector] || [] + : []; + const mainProductiveActivityOptions = centralProductiveActivity + ? ACTIVIDAD_PRINCIPAL_MAP[centralProductiveActivity] || [] + : []; + const productiveActivityOptions = mainProductiveActivity + ? ACTIVIDAD_PRODUCTIVA_MAP[mainProductiveActivity] || [] + : []; + + // Reset dependent fields when parent changes + React.useEffect(() => { + // This effect handles shifts in options, but react-hook-form values persist + // You might want to clear values if they are no longer valid, + // but for now we rely on the user making a valid selection. + }, [ + ecoSector, + productiveSector, + centralProductiveActivity, + mainProductiveActivity, + ]); + const { data: dataCoorState } = useStateQuery(); const { data: dataCoorMunicipality } = useMunicipalityQuery(coorState); const { data: dataCoorParish } = useParishQuery(coorMunicipality); - - const coorStateOptions = dataCoorState?.data || [{ id: 0, name: 'Sin estados' }]; + const coorStateOptions = dataCoorState?.data || [ + { id: 0, name: 'Sin estados' }, + ]; const coorMunicipalityOptions = - Array.isArray(dataCoorMunicipality?.data) && dataCoorMunicipality.data.length > 0 + Array.isArray(dataCoorMunicipality?.data) && + dataCoorMunicipality.data.length > 0 ? dataCoorMunicipality.data : [{ id: 0, stateId: 0, name: 'Sin Municipios' }]; @@ -195,7 +221,6 @@ export function CreateTrainingForm({ ? dataCoorParish.data : [{ id: 0, stateId: 0, name: 'Sin Parroquias' }]; - const stateOptions = dataState?.data || [{ id: 0, name: 'Sin estados' }]; const municipalityOptions = @@ -232,104 +257,27 @@ export function CreateTrainingForm({ } }, [defaultValues]); - const formatToLocalISO = (dateStr?: string | Date) => { - const date = dateStr ? new Date(dateStr) : new Date(); - const year = date.getFullYear(); - const month = String(date.getMonth() + 1).padStart(2, '0'); - const day = String(date.getDate()).padStart(2, '0'); - const hours = String(date.getHours()).padStart(2, '0'); - const minutes = String(date.getMinutes()).padStart(2, '0'); - return `${year}-${month}-${day}T${hours}:${minutes}`; - }; - - const form = useForm({ - resolver: zodResolver(trainingSchema), - defaultValues: { - firstname: defaultValues?.firstname || '', - lastname: defaultValues?.lastname || '', - coorState: defaultValues?.coorState || undefined, - coorMunicipality: defaultValues?.coorMunicipality || undefined, - coorParish: defaultValues?.coorParish || undefined, - coorPhone: defaultValues?.coorPhone || '', - visitDate: formatToLocalISO(defaultValues?.visitDate), - productiveActivity: defaultValues?.productiveActivity || '', - ecoSector: defaultValues?.ecoSector || undefined, - productiveSector: defaultValues?.productiveSector || undefined, - centralProductiveActivity: defaultValues?.centralProductiveActivity || '', - mainProductiveActivity: defaultValues?.mainProductiveActivity || '', - typesOfEquipment: defaultValues?.typesOfEquipment || '', - equipmentCount: defaultValues?.equipmentCount || 0, - equipmentDescription: defaultValues?.equipmentDescription || '', - rawMaterial: defaultValues?.rawMaterial || '', - materialType: defaultValues?.materialType || '', - rawMaterialCount: defaultValues?.rawMaterialCount || 0, - productCountDaily: defaultValues?.productCountDaily || 0, - productCountWeekly: defaultValues?.productCountWeekly || 0, - productCountMonthly: defaultValues?.productCountMonthly || 0, - // financialRequirementDescription: - // defaultValues?.financialRequirementDescription || '', - siturCodeCommune: defaultValues?.siturCodeCommune || '', - communeName: defaultValues?.communeName || '', - communeRif: defaultValues?.communeRif || '', - communeSpokespersonName: defaultValues?.communeSpokespersonName || '', - communeSpokespersonCedula: defaultValues?.communeSpokespersonCedula || '', - communeSpokespersonRif: defaultValues?.communeSpokespersonRif || '', - communeSpokespersonPhone: defaultValues?.communeSpokespersonPhone || '', - communeEmail: defaultValues?.communeEmail || '', - communalCouncil: defaultValues?.communalCouncil || '', - siturCodeCommunalCouncil: defaultValues?.siturCodeCommunalCouncil || '', - communalCouncilRif: defaultValues?.communalCouncilRif || '', - communalCouncilSpokespersonName: defaultValues?.communalCouncilSpokespersonName || '', - communalCouncilSpokespersonCedula: defaultValues?.communalCouncilSpokespersonCedula || '', - communalCouncilSpokespersonRif: defaultValues?.communalCouncilSpokespersonRif || '', - communalCouncilSpokespersonPhone: defaultValues?.communalCouncilSpokespersonPhone || '', - communalCouncilEmail: defaultValues?.communalCouncilEmail || '', - ospGoogleMapsLink: defaultValues?.ospGoogleMapsLink || '', - ospName: defaultValues?.ospName || '', - ospAddress: defaultValues?.ospAddress || '', - ospRif: defaultValues?.ospRif || '', - ospType: defaultValues?.ospType || '', - currentStatus: defaultValues?.currentStatus || 'ACTIVA', - companyConstitutionYear: - defaultValues?.companyConstitutionYear || new Date().getFullYear(), - producerCount: defaultValues?.producerCount || 0, - // productCount: defaultValues?.productCount || 0, - productDescription: defaultValues?.productDescription || '', - prodDescriptionInternal: defaultValues?.prodDescriptionInternal || '', - installedCapacity: defaultValues?.installedCapacity || '', - operationalCapacity: defaultValues?.operationalCapacity || '', - ospResponsibleFullname: defaultValues?.ospResponsibleFullname || '', - ospResponsibleCedula: defaultValues?.ospResponsibleCedula || '', - ospResponsibleRif: defaultValues?.ospResponsibleRif || '', - ospResponsiblePhone: defaultValues?.ospResponsiblePhone || '', - civilState: defaultValues?.civilState || '', - familyBurden: defaultValues?.familyBurden || 0, - numberOfChildren: defaultValues?.numberOfChildren || 0, - generalObservations: defaultValues?.generalObservations || '', - ospResponsibleEmail: defaultValues?.ospResponsibleEmail || '', - photo1: defaultValues?.photo1 || '', - photo2: defaultValues?.photo2 || '', - photo3: defaultValues?.photo3 || '', - paralysisReason: defaultValues?.paralysisReason || '', - state: defaultValues?.state || undefined, - municipality: defaultValues?.municipality || undefined, - parish: defaultValues?.parish || undefined, - internalCount: defaultValues?.internalCount || 0, - externalCount: defaultValues?.externalCount || 0, - prodDescriptionExternal: defaultValues?.prodDescriptionExternal || '', - country: defaultValues?.country || undefined, - city: defaultValues?.city || undefined, - menCount: defaultValues?.menCount || 0, - womenCount: defaultValues?.womenCount || 0, - }, - mode: 'onChange', - }); - const onSubmit = async (formData: TrainingSchema) => { const data = new FormData(); + // 1. Definimos las claves que NO queremos enviar en el bucle general + // 'files' se procesa aparte. + // 'photo1/2/3' son strings (urls viejas) que no queremos reenviar como texto. + const excludedKeys = ['files', 'photo1', 'photo2', 'photo3']; + Object.entries(formData).forEach(([key, value]) => { - if (key !== 'files' && value !== undefined && value !== null) { + // 2. Condición actualizada: Si la key está en la lista de excluidos, la saltamos + if (excludedKeys.includes(key) || value === undefined || value === null) { + return; + } + + // 3. Lógica de conversión (Igual que tenías) + if ( + Array.isArray(value) || + (typeof value === 'object' && !(value instanceof Date)) + ) { + data.append(key, JSON.stringify(value)); + } else { data.append(key, value.toString()); } }); @@ -338,6 +286,7 @@ export function CreateTrainingForm({ data.append('id', defaultValues.id.toString()); } + // 4. Aquí se agregan las NUEVAS fotos (binary) si el usuario seleccionó alguna selectedFiles.forEach((file) => { data.append('files', file); }); @@ -405,7 +354,7 @@ export function CreateTrainingForm({ name="lastname" render={({ field }) => ( - Apellido del coordinador Estadal + Apellido del Coordinador Estadal @@ -419,92 +368,26 @@ export function CreateTrainingForm({ name="coorPhone" render={({ field }) => ( - Telefono del coordinador Estadal + Teléfono - + )} /> - ( - - Estado - ({ - value: item.id.toString(), - label: item.name, - }))} - onValueChange={(value) => { - field.onChange(Number(value)); - setcoorState(Number(value)); - setDisabledCoorMunicipality(false); - setDisabledCoorParish(true); - }} - placeholder="Selecciona un estado" - defaultValue={field.value?.toString()} - /> - - - )} - /> - - ( - - Municipio - ({ - value: item.id.toString(), - label: item.name, - }))} - onValueChange={(value) => { - field.onChange(Number(value)); - setcoorMunicipality(Number(value)); - setDisabledCoorParish(false); - }} - placeholder="Selecciona un municipio" - disabled={disabledCoorMunicipality} - defaultValue={field.value?.toString()} - /> - - - )} - /> - - ( - - Parroquia - ({ - value: item.id.toString(), - label: item.name, - }))} - onValueChange={(value) => field.onChange(Number(value))} - placeholder="Selecciona una parroquia" - disabled={disabledCoorParish} - defaultValue={field.value?.toString()} - /> - - - )} - /> - ( - Fecha y hora de la visita + Fecha y Hora de la visita ( - Tipos de Organización + Tipo de Organización { + field.onChange(val); + // Reset downstream + form.setValue('productiveSector', ''); + form.setValue('centralProductiveActivity', ''); + form.setValue('mainProductiveActivity', ''); + form.setValue('productiveActivity', ''); + }} defaultValue={field.value} > @@ -571,7 +461,7 @@ export function CreateTrainingForm({ - {ECO_SECTORS.map((type) => ( + {SECTOR_ECONOMICO_OPTIONS.map((type) => ( {type} @@ -588,10 +478,16 @@ export function CreateTrainingForm({ name="productiveSector" render={({ field }) => ( - Sector Productivo + SECTOR PRODUCTIVO { + field.onChange(val); + form.setValue('mainProductiveActivity', ''); + form.setValue('productiveActivity', ''); + }} defaultValue={field.value} + disabled={!productiveSector} > - + - {CENTRAL_PRODUCTIVE_ACTIVITY.map((type) => ( + {centralProductiveActivityOptions.map((type) => ( {type} @@ -644,18 +545,22 @@ export function CreateTrainingForm({ name="mainProductiveActivity" render={({ field }) => ( - Actividad Productiva Principal + ACTIVIDAD PRODUCTIVA PRINCIPAL @@ -683,7 +589,7 @@ export function CreateTrainingForm({ - {PRODUCTIVE_ACTIVITIES.map((type) => ( + {productiveActivityOptions.map((type) => ( {type} @@ -700,7 +606,7 @@ export function CreateTrainingForm({ name="ospRif" render={({ field }) => ( - RIF de la Organización + RIF de la organización (opcional) @@ -714,7 +620,7 @@ export function CreateTrainingForm({ name="ospName" render={({ field }) => ( - Nombre de la Organización + Nombre de la organización @@ -723,34 +629,6 @@ export function CreateTrainingForm({ )} /> - {/* ( - - Actividad Productiva - - - - )} - /> */} - ( - - Razones de paralización (si aplica) - -