Skip to content

Commit

Permalink
Merge pull request #12 from cweidner3/develop
Browse files Browse the repository at this point in the history
Release to provide maria support
  • Loading branch information
cweidner3 authored Dec 10, 2022
2 parents 3046550 + 43cb3c2 commit 2330345
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/push-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
uses: docker/[email protected]
with:
images: ${{ secrets.DOCKER_HUB_NS }}/hikeblog-web
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Extract metadata (tags, labels) for Docker
id: metaapi
Expand Down
10 changes: 5 additions & 5 deletions api/src/db/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=missing-class-docstring
# pylint: disable=too-few-public-methods

from sqlalchemy import Boolean, Column, Float, ForeignKey, Integer, LargeBinary, Text
from sqlalchemy import Boolean, Column, Float, ForeignKey, Integer, LargeBinary, String, Text
from sqlalchemy.orm import relationship

from src.db.base import Base
Expand All @@ -11,7 +11,7 @@
class Timezone(Base):
__tablename__ = 'timezones'

name = Column(Text, primary_key=True, index=True)
name = Column(String(256), primary_key=True, index=True)


class Hike(Base):
Expand All @@ -21,7 +21,7 @@ class Hike(Base):
name = Column(Text, nullable=False)
start = Column(AwareDateTime)
end = Column(AwareDateTime)
zone = Column(Text, ForeignKey(Timezone.name), nullable=False, server_default='UTC')
zone = Column(Text, ForeignKey(Timezone.name), nullable=True, server_default='UTC')
title = Column(Text)
brief = Column(Text)
description = Column(Text)
Expand Down Expand Up @@ -128,7 +128,7 @@ class Picture(Base):
name = Column(Text, nullable=False)
fmt = Column(Text, nullable=False)
time = Column(AwareDateTime, nullable=False)
data = Column(LargeBinary, nullable=False)
data = Column(LargeBinary(1 << 24), nullable=False)
description = Column(Text)

@property
Expand All @@ -149,7 +149,7 @@ class ApiSession(Base):
__tablename__ = 'session'

id = Column(Integer, primary_key=True)
key = Column(Text, unique=True, nullable=False)
key = Column(String(256), unique=True, nullable=False)
username = Column(Text, nullable=False)
displayname = Column(Text, nullable=False)
admin = Column(Boolean, default=False)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from alembic import op
from sqlalchemy import Boolean, Column, Integer, Text
from sqlalchemy import Boolean, Column, Integer, Text, String
import uuid


Expand All @@ -21,7 +21,7 @@ def upgrade() -> None:
table = op.create_table(
'session',
Column('id', Integer, primary_key=True),
Column('key', Text, unique=True, nullable=False),
Column('key', String(256), unique=True, nullable=False),
Column('username', Text, nullable=False),
Column('displayname', Text, nullable=False),
Column('admin', Boolean, default=False),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
from alembic import op
import pytz
from sqlalchemy import Column, Date, DateTime, Text, ForeignKey
from sqlalchemy import Column, Date, DateTime, String, Text, ForeignKey


# revision identifiers, used by Alembic.
Expand All @@ -20,14 +20,13 @@
def upgrade() -> None:
tztable = op.create_table(
'timezones',
Column('name', Text, index=True, primary_key=True),
Column('name', String(256), index=True, primary_key=True),
)
assert tztable is not None
op.bulk_insert(tztable, list(map(lambda x: dict(name=x), pytz.common_timezones)))

op.add_column('hikes', Column('zone', Text, ForeignKey('timezones.name'), server_default='UTC'))
op.add_column('hikes', Column('zone', String(256), ForeignKey('timezones.name'), server_default='UTC'))
op.execute("UPDATE hikes SET zone = 'UTC'")
op.alter_column('hikes', 'zone', nullable=False)
op.alter_column('hikes', 'start', type_=DateTime)
op.alter_column('hikes', 'end', type_=DateTime)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Set LargeBinary size for MariaDB BLOB
Revision ID: 692e53a878cb
Revises: 991b63134bdc
Create Date: 2022-12-10 14:12:58.313588
"""
from alembic import op
from sqlalchemy import LargeBinary


# revision identifiers, used by Alembic.
revision = '692e53a878cb'
down_revision = '991b63134bdc'
branch_labels = None
depends_on = None


def upgrade() -> None:
op.alter_column('pictures', 'data', type_=LargeBinary(1 << 24))


def downgrade() -> None:
op.alter_column('pictures', 'data', type_=LargeBinary)
22 changes: 19 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ services:
build: ./api
environment:
APP_MODE: development
DB_DIALECT: postgres
DB_HOST: db
# DB_DIALECT: postgres
DB_DIALECT: mariadb
# DB_HOST: db
DB_HOST: mariadb
DB_NAME: db
DB_USER: postgres
# DB_USER: postgres
DB_USER: user
DB_PASS: secret
volumes:
- ./api/src:/app/src:ro
Expand All @@ -39,11 +42,24 @@ services:
volumes:
- db_data:/var/lib/postgresql/data

mariadb:
image: mariadb:10.3
environment:
MARIADB_USER: user
MARIADB_PASSWORD: secret
MARIADB_ROOT_PASSWORD: secret
MARIADB_DATABASE: db
ports:
- 3306:3306/tcp
volumes:
- maria_data:/var/lib/mysql

adminer:
image: adminer:4.8.1

volumes:
db_data: {}
maria_data: {}

configs:
proxy_conf:
Expand Down

0 comments on commit 2330345

Please sign in to comment.