diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f448f..e69de29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,123 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [1.0.1] - 2024-04-19 - -### Fixed - -- Fix ruff command to use the now mandatory `check` command for fixing - -### Added - -## [1.0.0] - 2024-02-13 - -### Added - -- Add versioning to the convention -- Mention the adherence to Python convention in README.md - -### Changed - -- Move wiki doc to repo for proper review / versioning -- Disable pyright bytes type promotions - -## [0.2.0] - 2024-02-05 - -### Changed - -- Adopt hatch-openzim for metadata computation -- Upgrade dependencies -- Upgrade to Python 3.11 + 3.12 (instead of 3.10 + 3.11) -- Fix ruff configuration in pyproject.toml to fix depreciation warning in 0.2 -- Fix Pyright ignore rules to adapt to breaking changes in 1.1.348 - -## [0.1.10] - 2023-12-12 - -### Fixed - -- Add package location to adapt to hatchling 1.19.0 - -## [0.1.9] - 2023-09-19 - -### Changed - -- Split Docker build for efficiency - -## [0.1.8] - 2023-08-17 - -### Added - -- Add sample Docker test configuration for daemon processes -- Add support for coverage HTML report - -### Fixed - -- Fix few invoke task arguments and help - - -## [0.1.7] - 2023-08-04 - -### Changed - -- Update dependencies - -## [0.1.6] - 2023-07-26 - -### Changed - -- Enhance CI to do more tests regarding Docker and Python build and publish dev image - -## [0.1.5] - 2023-07-24 - -### Changed - -- Source Python version from pyproject.toml -- Build Docker image in CI `Publish.yaml` - -### Fixed - -- Adjust Ruff rules ignored by default -- Use `no-cache-dir` for package install - -## [0.1.4] - 2023-07-17 - -### Added - -- Added debugpy - -## [0.1.3] - 2023-07-14 - -### Added - -- Added a `check` feature in hatch -- Added pyright wrapper to this feature -- Installed this feature in `dev` environment -- Used `check-pyright` task in QA workflow - -### Changed - -- Use major versions for workflows actions -- Enable `dev` in default hatch environment - -## [0.1.2] - 2023-07-13 - -### Fixed - -- Fix version to comply with SemVer - -## [0.1.1] - 2023-07-11 - -### Added - -- Add the scripts to lint's features, otherwise we can use the hatch run lint:* - - -## [0.1.0] - 2023-06-22 - -### Added - -- Initial version diff --git a/backend/src/backend/db/models.py b/backend/src/backend/db/models.py index a5dc792..25883c2 100644 --- a/backend/src/backend/db/models.py +++ b/backend/src/backend/db/models.py @@ -4,8 +4,8 @@ from ipaddress import IPv4Address from uuid import UUID -from sqlalchemy import DateTime, Enum, ForeignKey, UniqueConstraint, text -from sqlalchemy.dialects.postgresql import ARRAY, CITEXT, INET +from sqlalchemy import DateTime, Enum, ForeignKey, String, UniqueConstraint, text +from sqlalchemy.dialects.postgresql import ARRAY, INET from sqlalchemy.orm import ( DeclarativeBase, Mapped, @@ -24,9 +24,8 @@ class Base(MappedAsDataclass, DeclarativeBase): # type has to be used. type_annotation_map = { # noqa: RUF012 - str: CITEXT, # use case-insensitive strings on PostgreSQL backend list[str]: ARRAY( - item_type=CITEXT + item_type=String ), # transform Python list[str] into PostgreSQL Array of strings datetime: DateTime( timezone=False @@ -57,7 +56,7 @@ class Country(Base): name: Mapped[str] # full name of the country (in English) - worker_id: Mapped[UUID | None] = mapped_column(ForeignKey("worker.id"), init=False) + worker_id: Mapped[str | None] = mapped_column(ForeignKey("worker.id"), init=False) worker: Mapped[Worker | None] = relationship(back_populates="countries", init=False) mirrors: Mapped[list[Mirror]] = relationship( back_populates="country", @@ -94,12 +93,12 @@ class Mirror(Base): class Worker(Base): __tablename__ = "worker" - id: Mapped[UUID] = mapped_column( - init=False, primary_key=True, server_default=text("uuid_generate_v4()") - ) - # RSA public key for generating access tokens needed to make request to - # the web server - auth_info: Mapped[str] + id: Mapped[str] = mapped_column(primary_key=True) + # RSA public key in PKCS8 format for generating access tokens required + # to make requests to the web server + pubkey_pkcs8: Mapped[str] + pubkey_fingerprint: Mapped[str | None] + last_seen_on: Mapped[datetime | None] countries: Mapped[list[Country]] = relationship(back_populates="worker", init=False) diff --git a/backend/src/backend/migrations/versions/ef3115ef505c_set_up_database_models.py b/backend/src/backend/migrations/versions/0c273daa1ab0_set_up_database_models.py similarity index 67% rename from backend/src/backend/migrations/versions/ef3115ef505c_set_up_database_models.py rename to backend/src/backend/migrations/versions/0c273daa1ab0_set_up_database_models.py index 84a60ba..b7e3f87 100644 --- a/backend/src/backend/migrations/versions/ef3115ef505c_set_up_database_models.py +++ b/backend/src/backend/migrations/versions/0c273daa1ab0_set_up_database_models.py @@ -1,8 +1,8 @@ """set up database models -Revision ID: ef3115ef505c +Revision ID: 0c273daa1ab0 Revises: -Create Date: 2024-06-03 15:53:20.253276 +Create Date: 2024-06-04 11:56:53.888630 """ @@ -11,7 +11,7 @@ from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = "ef3115ef505c" +revision = "0c273daa1ab0" down_revision = None branch_labels = None depends_on = None @@ -34,12 +34,12 @@ def upgrade() -> None: sa.Enum(name="status", native_enum=False, create_constraint=True), nullable=True, ), - sa.Column("error", postgresql.CITEXT(), nullable=True), - sa.Column("isp", postgresql.CITEXT(), nullable=True), + sa.Column("error", sa.String(), nullable=True), + sa.Column("isp", sa.String(), nullable=True), sa.Column("ip_address", postgresql.INET(), nullable=True), - sa.Column("asn", postgresql.CITEXT(), nullable=True), - sa.Column("country", postgresql.CITEXT(), nullable=True), - sa.Column("location", postgresql.CITEXT(), nullable=True), + sa.Column("asn", sa.String(), nullable=True), + sa.Column("country", sa.String(), nullable=True), + sa.Column("location", sa.String(), nullable=True), sa.Column("latency", sa.Integer(), nullable=True), sa.Column("download_size", sa.Integer(), nullable=True), sa.Column("duration", sa.Integer(), nullable=True), @@ -48,21 +48,17 @@ def upgrade() -> None: ) op.create_table( "worker", - sa.Column( - "id", - sa.Uuid(), - server_default=sa.text("uuid_generate_v4()"), - nullable=False, - ), - sa.Column("auth_info", postgresql.CITEXT(), nullable=False), + sa.Column("id", sa.String(), nullable=False), + sa.Column("pubkey_pkcs8", sa.String(), nullable=False), + sa.Column("pubkey_fingerprint", sa.String(), nullable=True), sa.Column("last_seen_on", sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint("id", name=op.f("pk_worker")), ) op.create_table( "country", - sa.Column("code", postgresql.CITEXT(), nullable=False), - sa.Column("name", postgresql.CITEXT(), nullable=False), - sa.Column("worker_id", sa.Uuid(), nullable=True), + sa.Column("code", sa.String(), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.Column("worker_id", sa.String(), nullable=True), sa.ForeignKeyConstraint( ["worker_id"], ["worker.id"], name=op.f("fk_country_worker_id_worker") ), @@ -71,21 +67,19 @@ def upgrade() -> None: ) op.create_table( "mirror", - sa.Column("id", postgresql.CITEXT(), nullable=False), - sa.Column("base_url", postgresql.CITEXT(), nullable=False), + sa.Column("id", sa.String(), nullable=False), + sa.Column("base_url", sa.String(), nullable=False), sa.Column("enabled", sa.Boolean(), nullable=False), - sa.Column("region", postgresql.CITEXT(), nullable=True), - sa.Column("asn", postgresql.CITEXT(), nullable=True), + sa.Column("region", sa.String(), nullable=True), + sa.Column("asn", sa.String(), nullable=True), sa.Column("score", sa.Integer(), nullable=True), sa.Column("latitude", sa.Float(), nullable=True), sa.Column("longitude", sa.Float(), nullable=True), sa.Column("country_only", sa.Boolean(), nullable=True), sa.Column("region_only", sa.Boolean(), nullable=True), sa.Column("as_only", sa.Boolean(), nullable=True), - sa.Column( - "other_countries", postgresql.ARRAY(postgresql.CITEXT()), nullable=True - ), - sa.Column("country_code", postgresql.CITEXT(), nullable=False), + sa.Column("other_countries", postgresql.ARRAY(sa.String()), nullable=True), + sa.Column("country_code", sa.String(), nullable=False), sa.ForeignKeyConstraint( ["country_code"], ["country.code"],