From 3da9a4b0b8fa91784c64840a86702f7935e7c8c3 Mon Sep 17 00:00:00 2001 From: valencata Date: Wed, 24 Jul 2024 18:44:27 -0300 Subject: [PATCH] =?UTF-8?q?Re-estructuraci=C3=B3n=20de=20la=20base=20de=20?= =?UTF-8?q?datos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...724-01-create user_new_maxhp structure.sql | 84 ++++++++++ ...2-migrate user table to new_user_maxhp.sql | 158 ++++++++++++++++++ ScriptsDB/20240724-03-drop old user table.sql | 1 + ScriptsDB/20240724-04-rename user table.sql | 1 + ...724-05-create index for new user table.sql | 1 + 5 files changed, 245 insertions(+) create mode 100644 ScriptsDB/20240724-01-create user_new_maxhp structure.sql create mode 100644 ScriptsDB/20240724-02-migrate user table to new_user_maxhp.sql create mode 100644 ScriptsDB/20240724-03-drop old user table.sql create mode 100644 ScriptsDB/20240724-04-rename user table.sql create mode 100644 ScriptsDB/20240724-05-create index for new user table.sql diff --git a/ScriptsDB/20240724-01-create user_new_maxhp structure.sql b/ScriptsDB/20240724-01-create user_new_maxhp structure.sql new file mode 100644 index 00000000..5d558e88 --- /dev/null +++ b/ScriptsDB/20240724-01-create user_new_maxhp structure.sql @@ -0,0 +1,84 @@ +CREATE TABLE IF NOT EXISTS "user_new_maxhp" ( + "id" integer NOT NULL, + "account_id" integer NOT NULL, + "deleted" integer NOT NULL DEFAULT '0', + "name" varchar(30) NOT NULL, + "level" integer NOT NULL, + "exp" integer NOT NULL, + "genre_id" integer NOT NULL, + "race_id" integer NOT NULL, + "class_id" integer NOT NULL, + "home_id" integer NOT NULL, + "description" varchar(255) DEFAULT NULL, + "gold" integer NOT NULL, + "bank_gold" integer NOT NULL DEFAULT '0', + "free_skillpoints" integer NOT NULL, + "pets_saved" integer NOT NULL DEFAULT '0', + "spouse" integer NOT NULL DEFAULT '0', + "message_info" varchar(512) DEFAULT '', + "pos_map" integer NOT NULL, + "pos_x" integer NOT NULL, + "pos_y" integer NOT NULL, + "body_id" integer NOT NULL, + "head_id" integer NOT NULL, + "weapon_id" integer NOT NULL, + "helmet_id" integer NOT NULL, + "shield_id" integer NOT NULL, + "heading" integer NOT NULL DEFAULT '3', + "max_hp" integer NOT NULL DEFAULT '18', + "min_hp" integer NOT NULL, + "min_man" integer NOT NULL, + "min_sta" integer NOT NULL, + "min_ham" integer NOT NULL, + "min_sed" integer NOT NULL, + "killed_npcs" integer NOT NULL DEFAULT '0', + "killed_users" integer NOT NULL DEFAULT '0', + "invent_level" integer NOT NULL DEFAULT '0', + "is_naked" integer NOT NULL DEFAULT '0', + "is_poisoned" integer NOT NULL DEFAULT '0', + "is_incinerated" integer NOT NULL DEFAULT '0', + "is_dead" integer NOT NULL DEFAULT '0', + "is_sailing" integer NOT NULL DEFAULT '0', + "is_paralyzed" integer NOT NULL DEFAULT '0', + "is_silenced" integer NOT NULL DEFAULT '0', + "silence_minutes_left" integer DEFAULT '0', + "silence_elapsed_seconds" integer DEFAULT '0', + "is_mounted" integer NOT NULL DEFAULT '0', + "is_banned" integer DEFAULT '0', + "banned_by" varchar(30) NOT NULL DEFAULT '', + "ban_reason" varchar(255) DEFAULT '', + "counter_pena" integer NOT NULL DEFAULT '0', + "deaths" integer NOT NULL DEFAULT '0', + "ciudadanos_matados" integer NOT NULL DEFAULT '0', + "criminales_matados" integer NOT NULL DEFAULT '0', + "recibio_armadura_real" integer NOT NULL DEFAULT '0', + "recibio_armadura_caos" integer NOT NULL DEFAULT '0', + "recompensas_real" integer DEFAULT '0', + "recompensas_caos" integer DEFAULT '0', + "faction_score" integer DEFAULT '0', + "reenlistadas" integer NOT NULL DEFAULT '0', + "fecha_ingreso" timestamp NOT NULL DEFAULT current_timestamp, + "nivel_ingreso" integer DEFAULT NULL, + "matados_ingreso" integer DEFAULT NULL, + "status" integer DEFAULT '0', + "guild_index" integer DEFAULT '0', + "guild_aspirant_index" integer DEFAULT NULL, + "guild_rejected_because" varchar(255) DEFAULT NULL, + "chat_global" integer DEFAULT '1', + "chat_combate" integer DEFAULT '1', + "warnings" integer NOT NULL DEFAULT '0', + "elo" integer NOT NULL DEFAULT '1000', + "return_map" integer NOT NULL DEFAULT '0', + "return_x" integer NOT NULL DEFAULT '0', + "return_y" integer NOT NULL DEFAULT '0', + "last_logout" integer NOT NULL DEFAULT 0, + "is_locked_in_mao" boolean DEFAULT 0, + "is_logged" boolean NOT NULL DEFAULT 0, + "puntos_pesca" INTEGER DEFAULT 0, + "delete_code" varchar(8) DEFAULT '', + user_key varchar(128) DEFAULT '', + is_reset int not null default 0, is_published integer DEFAULT 0, price_in_mao INTEGER DEFAULT 0, + PRIMARY KEY("id" AUTOINCREMENT), + UNIQUE("id","account_id","deleted"), + CONSTRAINT "fk_user_account" FOREIGN KEY("account_id") REFERENCES "account"("id") ON DELETE CASCADE ON UPDATE CASCADE +); \ No newline at end of file diff --git a/ScriptsDB/20240724-02-migrate user table to new_user_maxhp.sql b/ScriptsDB/20240724-02-migrate user table to new_user_maxhp.sql new file mode 100644 index 00000000..12cef376 --- /dev/null +++ b/ScriptsDB/20240724-02-migrate user table to new_user_maxhp.sql @@ -0,0 +1,158 @@ +INSERT INTO "user_new_maxhp" ( + "id", + "account_id", + "deleted", + "name", + "level", + "exp", + "genre_id", + "race_id", + "class_id", + "home_id", + "description", + "gold", + "bank_gold", + "free_skillpoints", + "pets_saved", + "message_info", + "pos_map", + "pos_x", + "pos_y", + "body_id", + "head_id", + "weapon_id", + "helmet_id", + "shield_id", + "heading", + "min_hp", + "min_man", + "min_sta", + "min_ham", + "min_sed", + "killed_npcs", + "killed_users", + "invent_level", + "is_naked", + "is_poisoned", + "is_incinerated", + "is_dead", + "is_sailing", + "is_paralyzed", + "is_silenced", + "silence_minutes_left", + "silence_elapsed_seconds", + "is_mounted", + "is_banned", + "banned_by", + "ban_reason", + "counter_pena", + "deaths", + "ciudadanos_matados", + "criminales_matados", + "recibio_armadura_real", + "recibio_armadura_caos", + "recompensas_real", + "recompensas_caos", + "reenlistadas", + "fecha_ingreso", + "nivel_ingreso", + "matados_ingreso", + "status", + "guild_index", + "guild_aspirant_index", + "guild_rejected_because", + "chat_global", + "chat_combate", + "warnings", + "elo", + "return_map", + "return_x", + "return_y", + "last_logout", + "is_locked_in_mao", + "is_logged", + "puntos_pesca", + "delete_code", + "is_reset", + "is_published", + "price_in_mao" +) +SELECT + "id", + "account_id", + "deleted", + "name", + "level", + "exp", + "genre_id", + "race_id", + "class_id", + "home_id", + "description", + "gold", + "bank_gold", + "free_skillpoints", + "pets_saved", + "message_info", + "pos_map", + "pos_x", + "pos_y", + "body_id", + "head_id", + "weapon_id", + "helmet_id", + "shield_id", + "heading", + "min_hp", + "min_man", + "min_sta", + "min_ham", + "min_sed", + "killed_npcs", + "killed_users", + "invent_level", + "is_naked", + "is_poisoned", + "is_incinerated", + "is_dead", + "is_sailing", + "is_paralyzed", + "is_silenced", + "silence_minutes_left", + "silence_elapsed_seconds", + "is_mounted", + "is_banned", + "banned_by", + "ban_reason", + "counter_pena", + "deaths", + "ciudadanos_matados", + "criminales_matados", + "recibio_armadura_real", + "recibio_armadura_caos", + "recompensas_real", + "recompensas_caos", + "reenlistadas", + "fecha_ingreso", + "nivel_ingreso", + "matados_ingreso", + "status", + "guild_index", + "guild_aspirant_index", + "guild_rejected_because", + "chat_global", + "chat_combate", + "warnings", + "elo", + "return_map", + "return_x", + "return_y", + "last_logout", + "is_locked_in_mao", + "is_logged", + "puntos_pesca", + "delete_code", + "is_reset", + "is_published", + "price_in_mao" +FROM "user"; \ No newline at end of file diff --git a/ScriptsDB/20240724-03-drop old user table.sql b/ScriptsDB/20240724-03-drop old user table.sql new file mode 100644 index 00000000..96b591d0 --- /dev/null +++ b/ScriptsDB/20240724-03-drop old user table.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS "user"; \ No newline at end of file diff --git a/ScriptsDB/20240724-04-rename user table.sql b/ScriptsDB/20240724-04-rename user table.sql new file mode 100644 index 00000000..b1b5b204 --- /dev/null +++ b/ScriptsDB/20240724-04-rename user table.sql @@ -0,0 +1 @@ +ALTER TABLE "user_new_maxhp" RENAME TO "user"; \ No newline at end of file diff --git a/ScriptsDB/20240724-05-create index for new user table.sql b/ScriptsDB/20240724-05-create index for new user table.sql new file mode 100644 index 00000000..4bcf0f56 --- /dev/null +++ b/ScriptsDB/20240724-05-create index for new user table.sql @@ -0,0 +1 @@ +CREATE INDEX "user_index" ON "user" ("id", "account_id", "deleted"); \ No newline at end of file