Fix Alembic setup and add timestamp to TelegramFile

This commit is contained in:
Tulir Asokan
2018-02-20 00:11:44 +02:00
parent f9d2d32ef0
commit bbc5f99ae9
5 changed files with 114 additions and 10 deletions
+2 -1
View File
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from sqlalchemy import (Column, UniqueConstraint, ForeignKey, ForeignKeyConstraint, Integer,
String, Boolean)
BigInteger, String, Boolean)
from sqlalchemy.orm import relationship
from .base import Base
@@ -112,6 +112,7 @@ class TelegramFile(Base):
mxc = Column(String)
mime_type = Column(String)
was_converted = Column(Boolean)
timestamp = Column(BigInteger, primary_key=True)
def init(db_session):
+3 -1
View File
@@ -25,6 +25,7 @@ import logging
from PIL import Image
import magic
import time
from telethon.tl.functions.messages import *
from telethon.tl.functions.channels import *
@@ -815,7 +816,8 @@ class Portal:
uploaded = await intent.upload_file(file, mime_type)
db_file = DBTelegramFile(id=id, mxc=uploaded["content_uri"],
mime_type=mime_type, was_converted=image_converted)
mime_type=mime_type, was_converted=image_converted,
timestamp=int(time.time()))
self.db.add(db_file)
self.db.commit()