Q3Stats is now open source! :)

This commit is contained in:
2017-03-06 20:33:09 +01:00
commit bfdcb87cef
197 changed files with 16395 additions and 0 deletions

1
alembic/README Normal file
View File

@@ -0,0 +1 @@
Generic single-database configuration.

72
alembic/env.py Normal file
View File

@@ -0,0 +1,72 @@
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = None
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

24
alembic/script.py.mako Normal file
View File

@@ -0,0 +1,24 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}

View File

@@ -0,0 +1,35 @@
"""Create table `games`.
Revision ID: 32ecefbbf8d3
Revises:
Create Date: 2015-02-21 11:30:09.451628
"""
# revision identifiers, used by Alembic.
revision = '32ecefbbf8d3'
down_revision = None
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
import sqlalchemy.dialects.postgresql as pg
def upgrade():
op.create_table(
'games',
sa.Column('id', sa.Integer(), primary_key=True),
sa.Column('uuid', sa.String(36)),
sa.Column('map', sa.String(255), index=True),
sa.Column('date', sa.Date(), index=True),
sa.Column('time', sa.Time()),
sa.Column('fraglimit', sa.Integer()),
sa.Column('attrs', pg.JSON()),
sa.UniqueConstraint('uuid')
)
def downgrade():
op.drop_table('games')

View File

@@ -0,0 +1,44 @@
"""Create table `scores`.
Revision ID: 3509d93df7c
Revises: 32ecefbbf8d3
Create Date: 2015-02-21 13:27:28.102629
"""
# revision identifiers, used by Alembic.
revision = '3509d93df7c'
down_revision = '32ecefbbf8d3'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
import sqlalchemy.dialects.postgresql as pg
def upgrade():
op.create_table(
'scores',
sa.Column('id', sa.Integer(), primary_key=True),
sa.Column(
'game_id', sa.Integer(), sa.ForeignKey('games.id'), index=True
),
sa.Column('player', sa.String(255), index=True),
sa.Column('score', sa.Integer()),
sa.Column('kills', sa.Integer()),
sa.Column('deaths', sa.Integer()),
sa.Column('suicides', sa.Integer()),
sa.Column('net', sa.Integer()),
sa.Column('damage_taken', sa.Integer()),
sa.Column('damage_given', sa.Integer()),
sa.Column('total_health', sa.Integer()),
sa.Column('total_armor', sa.Integer()),
sa.Column('weapons', pg.JSON()),
sa.Column('items', pg.JSON()),
sa.Column('powerups', pg.JSON()),
)
def downgrade():
op.drop_table('scores')