Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-estructuración de la base de datos #608

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions ScriptsDB/20240724-01-create user_new_maxhp structure.sql
Original file line number Diff line number Diff line change
@@ -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
);
158 changes: 158 additions & 0 deletions ScriptsDB/20240724-02-migrate user table to new_user_maxhp.sql
Original file line number Diff line number Diff line change
@@ -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";
1 change: 1 addition & 0 deletions ScriptsDB/20240724-03-drop old user table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS "user";
1 change: 1 addition & 0 deletions ScriptsDB/20240724-04-rename user table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "user_new_maxhp" RENAME TO "user";
1 change: 1 addition & 0 deletions ScriptsDB/20240724-05-create index for new user table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX "user_index" ON "user" ("id", "account_id", "deleted");