mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 15:04:38 +01:00
Added db init script. Combined all schemas under schemas. Persisted
updates and init
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ savedata/*/
|
||||
*.exe
|
||||
*.lnk
|
||||
*.bat
|
||||
/docker/db-data
|
||||
@@ -17,6 +17,8 @@ Docker compose allows you to run multiple containers at once. The docker compose
|
||||
- pg admin (Admin interface to make db changes)
|
||||
- erupe
|
||||
|
||||
We automatically populate the database to the latest version on start. If you you are updating you will need to apply the new schemas manually.
|
||||
|
||||
Before we get started you should make sure the database info matches whats in the docker compose file for the environment variables `POSTGRES_PASSWORD`,`POSTGRES_USER` and `POSTGRES_DB`. You can set the host to be the service name `db`.
|
||||
|
||||
Here is a example of what you would put in the config.json if you was to leave the defaults. It is strongly recommended to change the password.
|
||||
@@ -30,29 +32,29 @@ Here is a example of what you would put in the config.json if you was to leave t
|
||||
},
|
||||
```
|
||||
|
||||
### Running up the database for the first time
|
||||
First we need to set up the database. This requires the schema and the patch schemas to be applied. This can be done by runnnig up both the db and pgadmin.
|
||||
Place this file within ./docker/config.json
|
||||
|
||||
You will need to do the same for your bins place these in ./docker/bin
|
||||
|
||||
# Setting up the web hosted materials
|
||||
Clone the Severs repo into ./docker/Severs
|
||||
|
||||
Make sure your hosts are pointing to where this is hosted
|
||||
|
||||
1. Pull the remote images and build a container image for erupe
|
||||
```bash
|
||||
docker-compose pull
|
||||
docker-compose build
|
||||
```
|
||||
2. Run up pgadmin and login using the username and password provided in `PGADMIN_DEFAULT_EMAIL` and `PGADMIN_DEFAULT_PASSWORD` note you will need to set up a new connection to the database internally. You will use the same host, database, username and password as above.
|
||||
```bash
|
||||
docker-compose run db pgadmin -d
|
||||
```
|
||||
3. Use pgadmin to restore the schema using the restore functionaltiy and they query tool for the patch-schemas.
|
||||
|
||||
4. Now run up the server you should see the server start correctly now.
|
||||
```bash
|
||||
docker-compose run server -d
|
||||
```
|
||||
|
||||
## Turning off the server safely
|
||||
```bash
|
||||
docker-compose stop
|
||||
```
|
||||
|
||||
## Turning off the server destructive
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
Make sure if you want to delete your data you delete the folders that persisted
|
||||
- ./docker/savedata
|
||||
- ./docker/db-data
|
||||
## Turning on the server again
|
||||
This boots the db pgadmin and the server in a detached state
|
||||
```bash
|
||||
|
||||
@@ -14,6 +14,15 @@ services:
|
||||
- POSTGRES_DB=erupe
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./db-data/:/var/lib/postgresql/data/
|
||||
- ../schemas/:/schemas/
|
||||
- ./init/setup.sh:/docker-entrypoint-initdb.d/setup.sh
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4
|
||||
restart: always
|
||||
@@ -23,17 +32,19 @@ services:
|
||||
ports:
|
||||
- "5050:80"
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
condition: service_healthy
|
||||
server:
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
condition: service_healthy
|
||||
# If using prebuilt container change paths and config
|
||||
build:
|
||||
context: ../
|
||||
volumes:
|
||||
- ../config.json:/app/erupe/config.json
|
||||
- ../bin:/app/erupe/bin
|
||||
- ../savedata:/app/erupe/savedata
|
||||
- ./config.json:/app/erupe/config.json
|
||||
- ./bin:/app/erupe/bin
|
||||
- ./savedata:/app/erupe/savedata
|
||||
ports:
|
||||
# (Make sure these match config.json)
|
||||
- "53312:53312" #Sign V1
|
||||
@@ -48,4 +59,13 @@ services:
|
||||
- "54006:54006"
|
||||
- "54007:54007"
|
||||
- "54008:54008"
|
||||
|
||||
web:
|
||||
image: httpd:latest
|
||||
container_name: my-apache-app
|
||||
ports:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- ./Servers:/usr/local/apache2/htdocs
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
22
docker/init/setup.sh
Normal file
22
docker/init/setup.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "INIT!"
|
||||
pg_restore --username="$POSTGRES_USER" --dbname="$POSTGRES_DB" --verbose /schemas/9.1-init.sql
|
||||
|
||||
|
||||
|
||||
echo "Updating!"
|
||||
|
||||
for file in /schemas/update-schema/*
|
||||
do
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -1 -f $file
|
||||
done
|
||||
|
||||
|
||||
|
||||
echo "Patching!"
|
||||
|
||||
for file in /schemas/patch-schema/*
|
||||
do
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" -1 -f $file
|
||||
done
|
||||
BIN
schemas/9.1-init.sql
Normal file
BIN
schemas/9.1-init.sql
Normal file
Binary file not shown.
241
schemas/update-schema/9.2-update.sql
Normal file
241
schemas/update-schema/9.2-update.sql
Normal file
@@ -0,0 +1,241 @@
|
||||
BEGIN;
|
||||
|
||||
DROP TABLE IF EXISTS public.fpoint_items;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.fpoint_items (
|
||||
id serial PRIMARY KEY,
|
||||
item_type integer,
|
||||
item_id integer,
|
||||
quantity integer,
|
||||
fpoints integer,
|
||||
trade_type integer
|
||||
);
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD bonus_quests INT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD daily_quests INT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD promo_points INT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_characters ADD rp_today INT DEFAULT 0;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_characters ADD rp_yesterday INT DEFAULT 0;
|
||||
|
||||
UPDATE public.characters SET savemercenary = NULL;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD rasta_id INT;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD pact_id INT;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD stampcard INT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters DROP COLUMN IF EXISTS gacha_prem;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters DROP COLUMN IF EXISTS gacha_trial;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters DROP COLUMN IF EXISTS frontier_points;
|
||||
|
||||
ALTER TABLE IF EXISTS public.users ADD IF NOT EXISTS gacha_premium INT;
|
||||
|
||||
ALTER TABLE IF EXISTS public.users ADD IF NOT EXISTS gacha_trial INT;
|
||||
|
||||
ALTER TABLE IF EXISTS public.users ADD IF NOT EXISTS frontier_points INT;
|
||||
|
||||
DROP TABLE IF EXISTS public.gacha_shop;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.gacha_shop (
|
||||
id SERIAL PRIMARY KEY,
|
||||
min_gr INTEGER,
|
||||
min_hr INTEGER,
|
||||
name TEXT,
|
||||
url_banner TEXT,
|
||||
url_feature TEXT,
|
||||
url_thumbnail TEXT,
|
||||
wide BOOLEAN,
|
||||
recommended BOOLEAN,
|
||||
gacha_type INTEGER,
|
||||
hidden BOOLEAN
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS public.gacha_shop_items;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.gacha_entries (
|
||||
id SERIAL PRIMARY KEY,
|
||||
gacha_id INTEGER,
|
||||
entry_type INTEGER,
|
||||
item_type INTEGER,
|
||||
item_number INTEGER,
|
||||
item_quantity INTEGER,
|
||||
weight INTEGER,
|
||||
rarity INTEGER,
|
||||
rolls INTEGER,
|
||||
frontier_points INTEGER,
|
||||
daily_limit INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.gacha_items (
|
||||
id SERIAL PRIMARY KEY,
|
||||
entry_id INTEGER,
|
||||
item_type INTEGER,
|
||||
item_id INTEGER,
|
||||
quantity INTEGER
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS public.stepup_state;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.gacha_stepup (
|
||||
gacha_id INTEGER,
|
||||
step INTEGER,
|
||||
character_id INTEGER
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS public.lucky_box_state;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.gacha_box (
|
||||
gacha_id INTEGER,
|
||||
entry_id INTEGER,
|
||||
character_id INTEGER
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS public.login_boost_state;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.login_boost (
|
||||
char_id INTEGER,
|
||||
week_req INTEGER,
|
||||
expiration TIMESTAMP WITH TIME ZONE,
|
||||
reset TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD COLUMN mezfes BYTEA;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ALTER COLUMN daily_time TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ALTER COLUMN guild_post_checked TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ALTER COLUMN boost_time TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ADD COLUMN IF NOT EXISTS cafe_reset TIMESTAMP WITHOUT TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ALTER COLUMN cafe_reset TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.distribution ALTER COLUMN deadline TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.events ALTER COLUMN start_time TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.feature_weapon ALTER COLUMN start_time TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.feature_weapon
|
||||
(
|
||||
start_time TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
featured INTEGER NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_alliances ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_applications ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_characters ALTER COLUMN joined_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_posts ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.characters ALTER COLUMN daily_time TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guilds ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.mail ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.stamps ALTER COLUMN hl_next TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.stamps ALTER COLUMN ex_next TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.titles ALTER COLUMN unlocked_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.titles ALTER COLUMN updated_at TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.users ALTER COLUMN last_login TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.users ALTER COLUMN return_expires TYPE TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_meals DROP COLUMN IF EXISTS expires;
|
||||
|
||||
ALTER TABLE IF EXISTS public.guild_meals ADD COLUMN IF NOT EXISTS created_at TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
DROP TABLE IF EXISTS public.account_ban;
|
||||
|
||||
DROP TABLE IF EXISTS public.account_history;
|
||||
|
||||
DROP TABLE IF EXISTS public.account_moderation;
|
||||
|
||||
DROP TABLE IF EXISTS public.account_sub;
|
||||
|
||||
DROP TABLE IF EXISTS public.history;
|
||||
|
||||
DROP TABLE IF EXISTS public.questlists;
|
||||
|
||||
DROP TABLE IF EXISTS public.schema_migrations;
|
||||
|
||||
DROP TABLE IF EXISTS public.user_binaries;
|
||||
|
||||
DROP PROCEDURE IF EXISTS raviinit;
|
||||
|
||||
DROP PROCEDURE IF EXISTS ravireset;
|
||||
|
||||
ALTER TABLE IF EXISTS public.normal_shop_items RENAME TO shop_items;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN shoptype TO shop_type;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN shopid TO shop_id;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN itemhash TO id;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN itemid TO item_id;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items ALTER COLUMN points TYPE integer;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN points TO cost;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN tradequantity TO quantity;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN rankreqlow TO min_hr;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN rankreqhigh TO min_sr;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN rankreqg TO min_gr;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN storelevelreq TO store_level;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN maximumquantity TO max_quantity;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items DROP COLUMN IF EXISTS boughtquantity;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN roadfloorsrequired TO road_floors;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items RENAME COLUMN weeklyfataliskills TO road_fatalis;
|
||||
|
||||
ALTER TABLE public.shop_items RENAME CONSTRAINT normal_shop_items_pkey TO shop_items_pkey;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items DROP CONSTRAINT IF EXISTS normal_shop_items_itemhash_key;
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS public.shop_items_id_seq;
|
||||
|
||||
ALTER SEQUENCE IF EXISTS public.shop_items_id_seq OWNER TO postgres;
|
||||
|
||||
ALTER TABLE IF EXISTS public.shop_items ALTER COLUMN id SET DEFAULT nextval('shop_items_id_seq'::regclass);
|
||||
|
||||
ALTER SEQUENCE IF EXISTS public.shop_items_id_seq OWNED BY shop_items.id;
|
||||
|
||||
SELECT setval('shop_items_id_seq', (SELECT MAX(id) FROM public.shop_items));
|
||||
|
||||
DROP TABLE IF EXISTS public.shop_item_state;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.shop_items_bought (
|
||||
character_id INTEGER,
|
||||
shop_item_id INTEGER,
|
||||
bought INTEGER
|
||||
);
|
||||
|
||||
UPDATE users SET rights = rights-2;
|
||||
|
||||
ALTER TABLE IF EXISTS public.users ALTER COLUMN rights SET DEFAULT 12;
|
||||
|
||||
END;
|
||||
Reference in New Issue
Block a user