Skip to content

Commit

Permalink
Merge pull request #23 from seatable/update-sqlalchemy
Browse files Browse the repository at this point in the history
update sqlalchemy
  • Loading branch information
freeplant authored Mar 11, 2024
2 parents 88d3bf0 + c4157d9 commit 57bead9
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 157 deletions.
28 changes: 9 additions & 19 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
FROM phusion/baseimage:0.11
FROM phusion/baseimage:focal-1.2.0
# docker.seafile.top/seafile-dev/seatable-thumbnail-server:1.x.x

# Aliyun ubuntu source
RUN rm -rf /etc/apt/sources.list
COPY scripts/my-ubuntu-source.list /etc/apt/sources.list

## Dev related libs
RUN apt-get update --fix-missing

Expand All @@ -17,20 +13,14 @@ RUN apt-get install -y nginx
# Mysql
RUN apt-get install -y mysql-client

# set python3.6 global
RUN apt-get install -y python3 python3-pip
RUN python3.6 -m pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple && rm -r /root/.cache/pip
RUN rm -f /usr/bin/python && \
rm -f /usr/bin/python3 && \
rm -f /usr/bin/pip && \
rm -f /usr/bin/pip3 && \
ln -s /usr/bin/python3.6 /usr/bin/python && \
ln -s /usr/bin/python3.6 /usr/bin/python3 && \
ln -s /usr/local/bin/pip3.6 /usr/bin/pip && \
ln -s /usr/local/bin/pip3.6 /usr/bin/pip3

RUN pip3 install uvicorn==0.16.0 pillow==8.4.0 sqlalchemy==1.4.6 pymysql==1.0.2 future==0.18.2 requests==2.27.1 redis==4.2.2 django==3.2.* \
-i https://mirrors.aliyun.com/pypi/simple && rm -r /root/.cache/pip
# set python3.8 global
RUN apt-get install -y python3.8 python3-pip python3-setuptools
RUN python3 -m pip install --upgrade pip && rm -r /root/.cache/pip && \
rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python && \
rm -f /usr/bin/pip && ln -s /usr/local/bin/pip3 /usr/bin/pip

RUN pip3 install uvicorn==0.16.0 pillow==10.2.* sqlalchemy==2.0.18 pymysql==1.0.* future==0.18.* requests==2.31.* redis==4.4.* django==4.2.* \
-i https://pypi.tuna.tsinghua.edu.cn/simple/ && rm -r /root/.cache/pip


# seatable-thumbnail
Expand Down
2 changes: 1 addition & 1 deletion docker/scripts/monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export SRC_DIR=/opt/seatable-thumbnail/
export LD_LIBRARY_PATH=/opt/seatable-thumbnail/seafile/lib/
export PYTHONPATH=/opt/seatable-thumbnail/seafile/lib/python3.6/site-packages/:/usr/lib/python3.6/dist-packages:/usr/lib/python3.6/site-packages:/usr/local/lib/python3.6/dist-packages:/usr/local/lib/python3.6/site-packages
export PYTHONPATH=/opt/seatable-thumbnail/seafile/lib/python3.8/site-packages/:/usr/lib/python3.8/dist-packages:/usr/lib/python3.8/site-packages:/usr/local/lib/python3.8/dist-packages:/usr/local/lib/python3.8/site-packages
export PATH=/opt/seatable-thumbnail/seafile/bin/:$PATH

export CCNET_CONF_DIR=/opt/seatable-thumbnail/ccnet
Expand Down
12 changes: 0 additions & 12 deletions docker/scripts/my-ubuntu-source.list

This file was deleted.

14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
uvicorn==0.16.0
pillow
sqlalchemy==1.4.6
pymysql
future # seaf-server
requests
redis
django==3.2.*
pillow==10.2.*
sqlalchemy==2.0.18
pymysql==1.0.*
future==0.18.* # seaf-server
requests==2.31.*
redis==4.4.*
django==4.2.*

# psd_tools
# moviepy
6 changes: 3 additions & 3 deletions seatable_thumbnail/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import DeclarativeBase, sessionmaker
import redis

import seatable_thumbnail.settings as settings
Expand All @@ -11,7 +10,8 @@
db_kwargs = dict(pool_recycle=300, echo=False, echo_pool=False)

engine = create_engine(db_url, **db_kwargs)
Base = declarative_base()
class Base(DeclarativeBase):
pass
DBSession = sessionmaker(bind=engine)


Expand Down
171 changes: 86 additions & 85 deletions seatable_thumbnail/models.py
Original file line number Diff line number Diff line change
@@ -1,140 +1,141 @@
from sqlalchemy import Column, Integer, String, ForeignKey, Index, DateTime, \
from sqlalchemy import Integer, String, ForeignKey, DateTime, \
Boolean, BigInteger, Text
from sqlalchemy.orm import mapped_column

from seatable_thumbnail import Base


class Workspaces(Base):
__tablename__ = 'workspaces'
id = Column(Integer, primary_key=True)
name = Column(String(255), nullable=True)
owner = Column(String(255), unique=True)
repo_id = Column(String(36), unique=True)
org_id = Column(Integer)
created_at = Column(DateTime)
id = mapped_column(Integer, primary_key=True)
name = mapped_column(String(255), nullable=True)
owner = mapped_column(String(255), unique=True)
repo_id = mapped_column(String(36), unique=True)
org_id = mapped_column(Integer)
created_at = mapped_column(DateTime)


class DTables(Base):
__tablename__ = 'dtables'
id = Column(Integer, primary_key=True)
workspace_id = Column(Integer, ForeignKey('workspaces.id'))
uuid = Column(String(36), unique=True)
name = Column(String(255))
creator = Column(String(255))
modifier = Column(String(255))
created_at = Column(DateTime)
updated_at = Column(DateTime)
deleted = Column(Boolean)
delete_time = Column(DateTime, nullable=True)
color = Column(String(50), nullable=True)
text_color = Column(String(50), nullable=True)
icon = Column(String(50), nullable=True)
id = mapped_column(Integer, primary_key=True)
workspace_id = mapped_column(Integer, ForeignKey('workspaces.id'))
uuid = mapped_column(String(36), unique=True)
name = mapped_column(String(255))
creator = mapped_column(String(255))
modifier = mapped_column(String(255))
created_at = mapped_column(DateTime)
updated_at = mapped_column(DateTime)
deleted = mapped_column(Boolean)
delete_time = mapped_column(DateTime, nullable=True)
color = mapped_column(String(50), nullable=True)
text_color = mapped_column(String(50), nullable=True)
icon = mapped_column(String(50), nullable=True)


class DTableShare(Base):
__tablename__ = 'dtable_share'
id = Column(BigInteger, primary_key=True)
dtable_id = Column(Integer, ForeignKey('dtables.id'))
from_user = Column(String(255), index=True)
to_user = Column(String(255), index=True)
permission = Column(String(15))
id = mapped_column(BigInteger, primary_key=True)
dtable_id = mapped_column(Integer, ForeignKey('dtables.id'))
from_user = mapped_column(String(255), index=True)
to_user = mapped_column(String(255), index=True)
permission = mapped_column(String(15))


class DTableGroupShare(Base):
__tablename__ = 'dtable_group_share'
id = Column(BigInteger, primary_key=True)
dtable_id = Column(Integer, ForeignKey('dtables.id'))
group_id = Column(Integer, index=True)
created_by = Column(String(255), index=True)
permission = Column(String(15))
created_at = Column(DateTime)
id = mapped_column(BigInteger, primary_key=True)
dtable_id = mapped_column(Integer, ForeignKey('dtables.id'))
group_id = mapped_column(Integer, index=True)
created_by = mapped_column(String(255), index=True)
permission = mapped_column(String(15))
created_at = mapped_column(DateTime)


class DTableViewUserShare(Base):
__tablename__ = 'dtable_view_user_share'
id = Column(BigInteger, primary_key=True)
dtable_id = Column(Integer, ForeignKey('dtables.id'))
from_user = Column(String(255), index=True)
to_user = Column(String(255), index=True)
permission = Column(String(15))
table_id = Column(String(36), index=True)
view_id = Column(String(36), index=True)
id = mapped_column(BigInteger, primary_key=True)
dtable_id = mapped_column(Integer, ForeignKey('dtables.id'))
from_user = mapped_column(String(255), index=True)
to_user = mapped_column(String(255), index=True)
permission = mapped_column(String(15))
table_id = mapped_column(String(36), index=True)
view_id = mapped_column(String(36), index=True)


class DTableViewGroupShare(Base):
__tablename__ = 'dtable_view_group_share'
id = Column(BigInteger, primary_key=True)
dtable_id = Column(Integer, ForeignKey('dtables.id'))
from_user = Column(String(255), index=True)
to_group_id = Column(Integer, index=True)
permission = Column(String(15))
table_id = Column(String(36), index=True)
view_id = Column(String(36), index=True)
id = mapped_column(BigInteger, primary_key=True)
dtable_id = mapped_column(Integer, ForeignKey('dtables.id'))
from_user = mapped_column(String(255), index=True)
to_group_id = mapped_column(Integer, index=True)
permission = mapped_column(String(15))
table_id = mapped_column(String(36), index=True)
view_id = mapped_column(String(36), index=True)


class DTableExternalLinks(Base):
__tablename__ = 'dtable_external_link'
id = Column(BigInteger, primary_key=True)
dtable_id = Column(Integer, ForeignKey('dtables.id'))
creator = Column(String(255))
token = Column(String(100), unique=True)
permission = Column(String(50))
view_cnt = Column(Integer)
create_at = Column(DateTime)
is_custom = Column(Boolean)
password = Column(String(128), nullable=True)
expire_date = Column(DateTime)
id = mapped_column(BigInteger, primary_key=True)
dtable_id = mapped_column(Integer, ForeignKey('dtables.id'))
creator = mapped_column(String(255))
token = mapped_column(String(100), unique=True)
permission = mapped_column(String(50))
view_cnt = mapped_column(Integer)
create_at = mapped_column(DateTime)
is_custom = mapped_column(Boolean)
password = mapped_column(String(128), nullable=True)
expire_date = mapped_column(DateTime)


class DjangoSession(Base):
__tablename__ = 'django_session'
session_key = Column(String(40), primary_key=True)
session_data = Column(Text)
expire_date = Column(DateTime)
session_key = mapped_column(String(40), primary_key=True)
session_data = mapped_column(Text)
expire_date = mapped_column(DateTime)


class DTableSystemPlugins(Base):
__tablename__ = 'dtable_system_plugin'
id = Column(Integer, primary_key=True)
added_by = Column(String(255))
added_time = Column(DateTime)
info = Column(Text)
name = Column(String(255), index=True)
id = mapped_column(Integer, primary_key=True)
added_by = mapped_column(String(255))
added_time = mapped_column(DateTime)
info = mapped_column(Text)
name = mapped_column(String(255), index=True)


class DTableCollectionTables(Base):
__tablename__ = 'dtable_collection_tables'
id = Column(Integer, primary_key=True)
username = Column(String(255), index=True)
workspace_id = Column(Integer, index=True)
dtable_uuid = Column(String(36), index=True)
config = Column(Text, nullable=True)
token = Column(String(36), unique=True)
created_at = Column(DateTime, nullable=True)
id = mapped_column(Integer, primary_key=True)
username = mapped_column(String(255), index=True)
workspace_id = mapped_column(Integer, index=True)
dtable_uuid = mapped_column(String(36), index=True)
config = mapped_column(Text, nullable=True)
token = mapped_column(String(36), unique=True)
created_at = mapped_column(DateTime, nullable=True)


class DepartmentsV2(Base):
__tablename__ = 'departments_v2'
id = Column(Integer, primary_key=True)
name = Column(String(255))
created_at = Column(DateTime)
parent_id = Column(Integer, index=True)
org_id = Column(Integer)
id_in_org = Column(Integer)
path = Column(String(1024), index=True)
id = mapped_column(Integer, primary_key=True)
name = mapped_column(String(255))
created_at = mapped_column(DateTime)
parent_id = mapped_column(Integer, index=True)
org_id = mapped_column(Integer)
id_in_org = mapped_column(Integer)
path = mapped_column(String(1024), index=True)


class DepartmentMembersV2(Base):
__tablename__ = 'department_members_v2'
id = Column(Integer, primary_key=True)
department_id = Column(Integer, ForeignKey('departments_v2.id'))
username = Column(String(255), index=True)
is_staff = Column(Boolean)
created_at = Column(DateTime)
id = mapped_column(Integer, primary_key=True)
department_id = mapped_column(Integer, ForeignKey('departments_v2.id'))
username = mapped_column(String(255), index=True)
is_staff = mapped_column(Boolean)
created_at = mapped_column(DateTime)


class DepartmentV2Groups(Base):
__tablename__ = 'department_v2_groups'
id = Column(Integer, primary_key=True)
department_id = Column(Integer, ForeignKey('departments_v2.id'))
group_id = Column(Integer, index=True)
id = mapped_column(Integer, primary_key=True)
department_id = mapped_column(Integer, ForeignKey('departments_v2.id'))
group_id = mapped_column(Integer, index=True)
Loading

0 comments on commit 57bead9

Please sign in to comment.