Procházet zdrojové kódy

Change type of stored timestamps to have timezone

jherve před 1 rokem
rodič
revize
2a517c91b9
1 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 4 2
      src/de_quoi_parle_le_monde/storage.py

+ 4 - 2
src/de_quoi_parle_le_monde/storage.py

@@ -99,8 +99,8 @@ class Storage:
                     name="site_id",
                     references="sites (id) ON DELETE CASCADE",
                 ),
-                Column(name="timestamp", type_="timestamp"),
-                Column(name="timestamp_virtual", type_="timestamp"),
+                Column(name="timestamp", type_="timestamp with time zone"),
+                Column(name="timestamp_virtual", type_="timestamp with time zone"),
                 Column(name="url_original", type_="TEXT"),
                 Column(name="url_snapshot", type_="TEXT"),
             ],
@@ -492,6 +492,8 @@ class Storage:
             ]
 
     async def add_page(self, collection, page, dt):
+        assert (dt.tzinfo is not None)
+
         async with self.backend.get_connection() as conn:
             async with conn.transaction():
                 site_id = await self._add_site(conn, collection.name, collection.url)