Erster Durchstich mit updates
This commit is contained in:
parent
d3fd60b548
commit
3331f08091
60 changed files with 693 additions and 195 deletions
16
tools/Dockerfile
Normal file
16
tools/Dockerfile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
FROM php:8.2-apache
|
||||
|
||||
# Install PDO MySQL extension
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
|
||||
# Enable Apache mod_rewrite for routing
|
||||
RUN a2enmod rewrite
|
||||
|
||||
# Set document root to public folder
|
||||
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
|
||||
|
||||
# Update Apache config to use the new document root
|
||||
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
||||
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||
|
||||
WORKDIR /var/www/html
|
||||
BIN
tools/__pycache__/deploy_test.cpython-312.pyc
Normal file
BIN
tools/__pycache__/deploy_test.cpython-312.pyc
Normal file
Binary file not shown.
242
tools/deploy_test.py
Executable file
242
tools/deploy_test.py
Executable file
|
|
@ -0,0 +1,242 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Deploy-Skript für das Testsystem tippspiel.programmschmiede.de.
|
||||
|
||||
Lädt das Projekt (tippspiel/public und tippspiel/src) per FTP auf den
|
||||
Testsystem-Server hoch und erzeugt dabei eine .htaccess mit den nötigen
|
||||
Environment-Variablen (SetEnv) im public/-Verzeichnis.
|
||||
|
||||
Zugangsdaten werden aus docs/testsystem_credentials.txt gelesen.
|
||||
Achtung: Zugangsdaten landen als SetEnv in der .htaccess auf dem Server.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from ftplib import FTP, error_perm
|
||||
|
||||
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
CRED_FILE = os.path.join(REPO_ROOT, "docs", "testsystem_credentials.txt")
|
||||
APP_DIR = os.path.join(REPO_ROOT, "tippspiel")
|
||||
|
||||
FTP_HOST = "programmschmiede.de"
|
||||
FTP_PORT = 21
|
||||
REMOTE_ROOT = "tippspiel.programmschmiede.de"
|
||||
|
||||
# Konfiguration des Testsystems (falls nicht in den Credentials vorhanden)
|
||||
DB_HOST = "localhost"
|
||||
DB_USER = "d0489c69"
|
||||
APP_URL = "https://tippspiel.programmschmiede.de"
|
||||
|
||||
# Quelle für den DB-Sync: lokale, bereits migrierte Datenbank (via Docker)
|
||||
LOCAL_DB_HOST = "127.0.0.1"
|
||||
LOCAL_DB_PORT = "3306"
|
||||
LOCAL_DB_USER = "root"
|
||||
LOCAL_DB_PASS = "root"
|
||||
LOCAL_DB_NAME = "tippspiel2027"
|
||||
|
||||
# Entfernte DB, in die der Dump eingespielt wird
|
||||
REMOTE_DB_HOST = "programmschmiede.de"
|
||||
REMOTE_DB_PORT = "3306"
|
||||
|
||||
|
||||
def read_credentials(path):
|
||||
creds = {}
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
key, _, value = line.partition("=")
|
||||
creds[key.strip()] = value.strip()
|
||||
return creds
|
||||
|
||||
|
||||
def build_htaccess(creds):
|
||||
return "\n".join(
|
||||
[
|
||||
"# Auto-generiert von deploy_test.py - NICHT manuell editieren",
|
||||
"Options -Indexes",
|
||||
"",
|
||||
"RewriteEngine On",
|
||||
"RewriteCond %{HTTPS} off",
|
||||
"RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]",
|
||||
"",
|
||||
"SetEnv DB_HOST " + DB_HOST,
|
||||
"SetEnv DB_USER " + DB_USER,
|
||||
"SetEnv DB_PASS " + creds["mysql_pw"],
|
||||
"SetEnv DB_NEW_NAME " + creds["mysql_db"],
|
||||
"SetEnv APP_URL " + APP_URL,
|
||||
"",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def run(cmd, env=None, input_data=None):
|
||||
"""Führt einen Befehl aus und gibt bei Fehlern eine verständliche Meldung aus."""
|
||||
proc = subprocess.run(
|
||||
cmd,
|
||||
env=env,
|
||||
input=input_data,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError(
|
||||
"Befehl fehlgeschlagen: %s\n%s" % (" ".join(cmd), proc.stderr.decode("utf-8", "replace"))
|
||||
)
|
||||
return proc.stdout
|
||||
|
||||
|
||||
def sync_database(creds):
|
||||
"""Dumpt die lokale migrierte DB und spielt sie in die entfernte Test-DB ein."""
|
||||
remote_db = creds["mysql_db"]
|
||||
remote_pw = creds["mysql_pw"]
|
||||
|
||||
print("== DB-Sync: dumpe lokale '%s' ==" % LOCAL_DB_NAME)
|
||||
dump_env = dict(os.environ, MYSQL_PWD=LOCAL_DB_PASS)
|
||||
dump = run(
|
||||
[
|
||||
"mysqldump",
|
||||
"-h", LOCAL_DB_HOST, "-P", LOCAL_DB_PORT,
|
||||
"-u", LOCAL_DB_USER,
|
||||
"--no-tablespaces", "--column-statistics=0",
|
||||
"--no-create-db",
|
||||
LOCAL_DB_NAME,
|
||||
],
|
||||
env=dump_env,
|
||||
)
|
||||
|
||||
print("== DB-Sync: leere entfernte '%s' ==" % remote_db)
|
||||
remote_env = dict(os.environ, MYSQL_PWD=remote_pw)
|
||||
|
||||
# Alle vorhandenen Tabellen ermitteln und droppen
|
||||
tables_out = run(
|
||||
[
|
||||
"mysql",
|
||||
"-h", REMOTE_DB_HOST, "-P", REMOTE_DB_PORT,
|
||||
"-u", DB_USER, remote_db,
|
||||
"-N", "-e",
|
||||
"SELECT table_name FROM information_schema.tables WHERE table_schema='%s';" % remote_db,
|
||||
],
|
||||
env=remote_env,
|
||||
)
|
||||
tables = [t.strip() for t in tables_out.decode("utf-8", "replace").splitlines() if t.strip()]
|
||||
if tables:
|
||||
drop_sql = "SET FOREIGN_KEY_CHECKS=0; " + " ".join(
|
||||
"DROP TABLE IF EXISTS `%s`;" % t for t in tables
|
||||
) + " SET FOREIGN_KEY_CHECKS=1;"
|
||||
run(
|
||||
[
|
||||
"mysql",
|
||||
"-h", REMOTE_DB_HOST, "-P", REMOTE_DB_PORT,
|
||||
"-u", DB_USER, remote_db,
|
||||
"-e", drop_sql,
|
||||
],
|
||||
env=remote_env,
|
||||
)
|
||||
print(" %d Tabellen gelöscht." % len(tables))
|
||||
else:
|
||||
print(" keine Tabellen vorhanden.")
|
||||
|
||||
print("== DB-Sync: spiele Dump in '%s' ein ==" % remote_db)
|
||||
with tempfile.NamedTemporaryFile("wb", delete=False, suffix=".sql") as tmp:
|
||||
tmp.write(dump)
|
||||
dump_path = tmp.name
|
||||
try:
|
||||
with open(dump_path, "rb") as f:
|
||||
run(
|
||||
[
|
||||
"mysql",
|
||||
"-h", REMOTE_DB_HOST, "-P", REMOTE_DB_PORT,
|
||||
"-u", DB_USER, remote_db,
|
||||
],
|
||||
env=remote_env,
|
||||
input_data=f.read(),
|
||||
)
|
||||
finally:
|
||||
os.unlink(dump_path)
|
||||
|
||||
|
||||
def mkd_ignore_exists(ftp, name):
|
||||
try:
|
||||
ftp.mkd(name)
|
||||
except error_perm as e:
|
||||
if not e.args[0].startswith("550"):
|
||||
raise
|
||||
|
||||
|
||||
def upload_dir(ftp, local_dir, remote_dir):
|
||||
mkd_ignore_exists(ftp, remote_dir)
|
||||
for name in sorted(os.listdir(local_dir)):
|
||||
local_path = os.path.join(local_dir, name)
|
||||
if os.path.isfile(local_path):
|
||||
print("STOR", remote_dir + "/" + name)
|
||||
with open(local_path, "rb") as f:
|
||||
ftp.storbinary("STOR " + name, f)
|
||||
elif os.path.isdir(local_path):
|
||||
print("DIR ", remote_dir + "/" + name)
|
||||
mkd_ignore_exists(ftp, name)
|
||||
ftp.cwd(name)
|
||||
upload_dir(ftp, local_path, remote_dir + "/" + name)
|
||||
ftp.cwd("..")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Deploy auf das Testsystem.")
|
||||
parser.add_argument(
|
||||
"--skip-db-import",
|
||||
action="store_true",
|
||||
help="DB-Sync überspringen (keine Daten in die entfernte DB einspielen).",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not os.path.isfile(CRED_FILE):
|
||||
print("Fehler: Credentials nicht gefunden:", CRED_FILE, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
creds = read_credentials(CRED_FILE)
|
||||
for key in ("ftp_user", "ftp_pw", "mysql_db", "mysql_pw"):
|
||||
if key not in creds:
|
||||
print("Fehler: Fehlender Eintrag '%s' in %s" % (key, CRED_FILE), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
htaccess = build_htaccess(creds)
|
||||
|
||||
if args.skip_db_import:
|
||||
print("== DB-Sync übersprungen (--skip-db-import) ==")
|
||||
else:
|
||||
sync_database(creds)
|
||||
|
||||
ftp = FTP()
|
||||
ftp.connect(FTP_HOST, FTP_PORT)
|
||||
ftp.login(creds["ftp_user"], creds["ftp_pw"])
|
||||
|
||||
mkd_ignore_exists(ftp, REMOTE_ROOT)
|
||||
ftp.cwd(REMOTE_ROOT)
|
||||
|
||||
for sub in ("public", "src"):
|
||||
local_sub = os.path.join(APP_DIR, sub)
|
||||
if not os.path.isdir(local_sub):
|
||||
print("Fehler: Verzeichnis fehlt:", local_sub, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print("== Lade", sub, "hoch ==")
|
||||
mkd_ignore_exists(ftp, sub)
|
||||
ftp.cwd(sub)
|
||||
upload_dir(ftp, local_sub, REMOTE_ROOT + "/" + sub)
|
||||
ftp.cwd("..")
|
||||
|
||||
print("== Schreibe .htaccess in public/ ==")
|
||||
ftp.cwd("public")
|
||||
ftp.storbinary("STOR .htaccess", io.BytesIO(htaccess.encode("utf-8")))
|
||||
ftp.cwd("..")
|
||||
|
||||
ftp.quit()
|
||||
print("\nDeployment abgeschlossen ->", APP_URL)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
43
tools/docker-compose.yml
Normal file
43
tools/docker-compose.yml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
services:
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- .:/var/www/html
|
||||
- ../tippspiel/public:/var/www/html/public
|
||||
- ../tippspiel/src:/var/www/html/src
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_USER=root
|
||||
- DB_PASS=root
|
||||
- DB_OLD_NAME=tippspiel_legacy
|
||||
- DB_NEW_NAME=tippspiel2027
|
||||
# Lokal fängt Mailpit alle Mails ab (Weboberfläche: http://localhost:8025)
|
||||
- SMTP_HOST=mailpit
|
||||
- SMTP_PORT=1025
|
||||
- SMTP_ENCRYPTION=none
|
||||
- MAIL_FROM=hoschis.tippspiel.info@gmail.com
|
||||
- MAIL_FROM_NAME=Hoschis Tippspiel
|
||||
- APP_URL=http://localhost:8080
|
||||
- REMINDER_TOKEN=lokal-geheim
|
||||
depends_on:
|
||||
- db
|
||||
- mailpit
|
||||
|
||||
mailpit:
|
||||
image: axllent/mailpit
|
||||
ports:
|
||||
- "8025:8025"
|
||||
|
||||
db:
|
||||
image: mariadb:10.11
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=root
|
||||
volumes:
|
||||
- db_data:/var/lib/mysql
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
94
tools/import.php
Normal file
94
tools/import.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
// Import Script für tippspiel2027
|
||||
// Dieses Skript verbindet sich mit einer alten Datenbank (wo der Live-Dump importiert wurde)
|
||||
// und kopiert die relevanten Daten in die neue tippspiel2027 Datenbank.
|
||||
// Tote Features wie "Spieler Ligen" und "grünes Trikot" werden ignoriert.
|
||||
|
||||
$host = getenv('DB_HOST') ?: '127.0.0.1';
|
||||
$user = getenv('DB_USER') ?: 'root';
|
||||
$pass = getenv('DB_PASS') ?: '';
|
||||
$oldDbName = getenv('DB_OLD_NAME') ?: 'tippspiel_legacy';
|
||||
$newDbName = getenv('DB_NEW_NAME') ?: 'tippspiel2027';
|
||||
|
||||
try {
|
||||
$pdo = new PDO("mysql:host=$host;charset=utf8mb4", $user, $pass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
echo "Erstelle neue Datenbank $newDbName falls nicht vorhanden...\n";
|
||||
$pdo->exec("CREATE DATABASE IF NOT EXISTS `$newDbName` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
|
||||
|
||||
// Neues Schema laden
|
||||
$pdo->exec("USE `$newDbName`");
|
||||
$schema = file_get_contents(__DIR__ . '/schema.sql');
|
||||
if ($schema) {
|
||||
$pdo->exec($schema);
|
||||
echo "Neues Schema erfolgreich in $newDbName angelegt.\n";
|
||||
} else {
|
||||
die("Fehler: schema.sql nicht gefunden.\n");
|
||||
}
|
||||
|
||||
echo "Starte Import von $oldDbName nach $newDbName...\n";
|
||||
|
||||
$tablesToMigrate = [
|
||||
'users',
|
||||
'settings',
|
||||
'seasons',
|
||||
'rounds',
|
||||
'games',
|
||||
'tipps',
|
||||
'payments',
|
||||
'quotas',
|
||||
'roundmails',
|
||||
'manual_payouts'
|
||||
];
|
||||
|
||||
foreach ($tablesToMigrate as $table) {
|
||||
echo "Migriere Tabelle: $table...\n";
|
||||
|
||||
// Prüfen, ob Tabelle in der alten DB existiert
|
||||
$tableExists = $pdo->query("SELECT 1 FROM information_schema.tables WHERE table_schema = '$oldDbName' AND table_name = '$table'")->fetchColumn();
|
||||
if (!$tableExists) {
|
||||
echo " Überspringe $table, existiert in $oldDbName nicht.\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Leeren der neuen Tabelle
|
||||
$pdo->exec("TRUNCATE TABLE `$newDbName`.`$table`");
|
||||
|
||||
// Alle Daten aus alter DB holen
|
||||
$rows = $pdo->query("SELECT * FROM `$oldDbName`.`$table`")->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($rows) === 0) {
|
||||
echo " Keine Daten in $table.\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Holen der Spalten der NEUEN Tabelle (um Legacy Felder zu ignorieren)
|
||||
$newColsStmt = $pdo->query("DESCRIBE `$newDbName`.`$table`");
|
||||
$newCols = $newColsStmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
$inserted = 0;
|
||||
foreach ($rows as $row) {
|
||||
$filteredRow = [];
|
||||
foreach ($newCols as $col) {
|
||||
if (array_key_exists($col, $row)) {
|
||||
$filteredRow[$col] = $row[$col];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filteredRow)) {
|
||||
$cols = '`' . implode('`, `', array_keys($filteredRow)) . '`';
|
||||
$vals = implode(', ', array_fill(0, count($filteredRow), '?'));
|
||||
$stmt = $pdo->prepare("INSERT INTO `$newDbName`.`$table` ($cols) VALUES ($vals)");
|
||||
$stmt->execute(array_values($filteredRow));
|
||||
$inserted++;
|
||||
}
|
||||
}
|
||||
echo " $inserted Einträge migriert.\n";
|
||||
}
|
||||
|
||||
echo "Import erfolgreich abgeschlossen!\n";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Datenbankfehler: " . $e->getMessage() . "\n");
|
||||
}
|
||||
54
tools/import_from_dump.sh
Executable file
54
tools/import_from_dump.sh
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Importiert den neuesten Live-Dump des Legacy-Projekts in die lokale Test-DB
|
||||
# und migriert ihn anschließend in tippspiel2027 (import.php).
|
||||
#
|
||||
# Ablauf:
|
||||
# 1. Colima (Docker-Daemon) starten, falls noch nicht aktiv
|
||||
# 2. Neuesten Dump finden (/home/torsten/repos/tippspiel/tools/pfosten*.sql)
|
||||
# 3. Container starten und auf die DB warten
|
||||
# 4. Legacy-DB "tippspiel_legacy" droppen und neu anlegen
|
||||
# 5. Dump in "tippspiel_legacy" einspielen
|
||||
# 6. import.php ausführen (befüllt tippspiel2027 von scratch)
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DUMP_DIR="${DUMP_DIR:-/home/torsten/repos/tippspiel/tools}"
|
||||
LEGACY_DB="${DB_OLD_NAME:-tippspiel_legacy}"
|
||||
|
||||
DUMP="$(ls -1 "$DUMP_DIR"/pfosten*.sql | tail -1)"
|
||||
if [[ -z "$DUMP" ]]; then
|
||||
echo "Fehler: Kein Dump (pfosten*.sql) in $DUMP_DIR gefunden." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Verwende Dump: $DUMP"
|
||||
|
||||
if command -v colima >/dev/null 2>&1 && ! colima status >/dev/null 2>&1; then
|
||||
echo "Colima ist nicht aktiv, starte es..."
|
||||
colima start
|
||||
fi
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
docker compose up -d
|
||||
|
||||
echo "Warte auf die Datenbank..."
|
||||
for _ in $(seq 1 60); do
|
||||
if docker compose exec -T db mysql -uroot -proot -e "SELECT 1;" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
docker compose exec -T db mysql -uroot -proot -e "SELECT 1;" >/dev/null
|
||||
|
||||
echo "Lege Legacy-DB '$LEGACY_DB' neu an..."
|
||||
docker compose exec -T db mysql -uroot -proot \
|
||||
-e "DROP DATABASE IF EXISTS \`$LEGACY_DB\`; CREATE DATABASE \`$LEGACY_DB\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||||
|
||||
echo "Spiele Dump in '$LEGACY_DB' ein..."
|
||||
docker exec -i "$(docker compose ps -q db)" mysql -uroot -proot "$LEGACY_DB" < "$DUMP"
|
||||
|
||||
echo "Führe DB-Import aus (tippspiel2027)..."
|
||||
docker compose exec -T app php import.php
|
||||
|
||||
echo ""
|
||||
echo "Fertig. Öffne die Anwendung im Browser: http://localhost:8080"
|
||||
135
tools/schema.sql
Normal file
135
tools/schema.sql
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
DROP TABLE IF EXISTS `users`;
|
||||
CREATE TABLE `users` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(201) NOT NULL,
|
||||
`firstname` varchar(100) DEFAULT NULL,
|
||||
`lastname` varchar(100) DEFAULT NULL,
|
||||
`email` varchar(150) NOT NULL,
|
||||
`password` varchar(100) NOT NULL,
|
||||
`iban` varchar(128) DEFAULT NULL,
|
||||
`bankname` varchar(64) DEFAULT NULL,
|
||||
`blz` varchar(20) DEFAULT NULL,
|
||||
`kontonr` varchar(64) DEFAULT NULL,
|
||||
`mobile` varchar(255) DEFAULT NULL,
|
||||
`deleted` timestamp NULL DEFAULT NULL,
|
||||
`admin` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`gets_reminders` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `users_email_unique` (`email`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `tipps`;
|
||||
CREATE TABLE `tipps` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`game_id` int(11) NOT NULL,
|
||||
`score1` int(11) NOT NULL,
|
||||
`score2` int(11) NOT NULL,
|
||||
`joker` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `tipps_user_game_unique` (`user_id`, `game_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `games`;
|
||||
CREATE TABLE `games` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`round_id` int(11) NOT NULL,
|
||||
`team1` varchar(100) NOT NULL,
|
||||
`team2` varchar(100) NOT NULL,
|
||||
`score1` int(11) NOT NULL DEFAULT '-1',
|
||||
`score2` int(11) NOT NULL DEFAULT '-1',
|
||||
`kickoff` datetime NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `rounds`;
|
||||
CREATE TABLE `rounds` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`season_id` int(11) NOT NULL,
|
||||
`report` text,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `seasons`;
|
||||
CREATE TABLE `seasons` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`rounds` int(11) NOT NULL DEFAULT '36',
|
||||
`max_identical_jokertipps` int(11) NOT NULL DEFAULT '6',
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `settings`;
|
||||
CREATE TABLE `settings` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`current_season_id` int(11) NOT NULL,
|
||||
`registration_open` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `payments`;
|
||||
CREATE TABLE `payments` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`season_id` int(11) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`paid_date` datetime DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `quotas`;
|
||||
CREATE TABLE `quotas` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`season_id` int(11) NOT NULL DEFAULT '0',
|
||||
`name` varchar(100) NOT NULL,
|
||||
`order` int(11) NOT NULL DEFAULT '0',
|
||||
`prc` double NOT NULL DEFAULT '0',
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `roundmails`;
|
||||
CREATE TABLE `roundmails` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`send_date` date NOT NULL,
|
||||
`recipients` text NOT NULL,
|
||||
`topic` varchar(200) NOT NULL,
|
||||
`message` text NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `manual_payouts`;
|
||||
CREATE TABLE `manual_payouts` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`season_id` int(11) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`quota_name` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `password_resets`;
|
||||
CREATE TABLE `password_resets` (
|
||||
`email` varchar(150) NOT NULL,
|
||||
`token` varchar(100) NOT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
KEY `password_resets_email_index` (`email`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue