diff --git a/instark/core/data/sql/migrations/003_create_selections_table.py b/instark/core/data/sql/migrations/003_create_selections_table.py new file mode 100755 index 0000000..d998a0a --- /dev/null +++ b/instark/core/data/sql/migrations/003_create_selections_table.py @@ -0,0 +1,28 @@ +class Migration: # pragma: no cover + version = '003' + + def __init__(self, context): + self.context = context + self.connection = context['connection'] + self.schema = context['schema'] + self.owner = "instark" + self._tables = ["channels", "devices", "messages", + "subscriptions"] + + def _create_table(self, table): + return ( + f"CREATE TABLE IF NOT EXISTS {self.schema}.{table} (data JSONB);" + f"ALTER TABLE {self.schema}.{table} OWNER TO {self.owner};" + f"CREATE UNIQUE INDEX IF NOT EXISTS {table}_id_key ON " + f"{self.schema}.{table} ((data->>'id'));" + ) + + def schema_up(self): + statement = "" + for table in self._tables: + statement += self._create_table(table) + + self.connection.execute(statement) + + def schema_down(self): + """Not implemented.""" diff --git a/instark/presenters/rest/rest.py b/instark/presenters/rest/rest.py index 2c88c70..159eee3 100644 --- a/instark/presenters/rest/rest.py +++ b/instark/presenters/rest/rest.py @@ -1,4 +1,3 @@ -import aiohttp_cors import aiohttp_jinja2 from typing import Any from pathlib import Path @@ -29,17 +28,10 @@ def _setup(self) -> None: aiohttp_jinja2.setup(self, loader=FileSystemLoader(templates)) self.cleanup_ctx.append(self._http_client) - cors = aiohttp_cors.setup(self, defaults={ - "*": aiohttp_cors.ResourceOptions( - allow_credentials=True, expose_headers="*", - allow_headers="*")}) # API endpoints creation self._create_api() - for route in list(self.router.routes()): - cors.add(route) - @staticmethod async def _http_client(app: web.Application): session = ClientSession() diff --git a/requirements.txt b/requirements.txt index 7fc6fba..e187052 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,34 +1,20 @@ aiocontextvars==0.2.2 aiohttp==3.6.2 -aiohttp-cors==0.7.0 aiohttp-jinja2==1.2.0 -alabaster==0.7.12 -aniso8601==7.0.0 -ansible==2.8.4 +aiomcache==0.6.0 apispec==3.3.2 -appdirs==1.4.3 -argh==0.26.2 -asn1crypto==0.24.0 -astroid==2.2.5 async-timeout==3.0.1 -asyncmock==0.4.1 asyncpg==0.21.0 -atomicwrites==1.3.0 +atomicwrites==1.4.0 attrs==20.1.0 -autopep8==1.4.4 -Babel==2.7.0 -bcrypt==3.1.7 +autopep8==1.5.4 +bump2version==1.0.0 CacheControl==0.12.6 cachetools==4.1.1 certifi==2020.6.20 cffi==1.14.2 chardet==3.0.4 -colorama==0.4.3 -contextlib2==0.6.0 coverage==5.2.1 -cryptography==2.7 -distlib==0.3.0 -distro==1.4.0 filtrark==0.9.3 firebase-admin==4.3.0 google-api-core==1.22.1 @@ -42,53 +28,45 @@ google-crc32c==1.0.0 google-resumable-media==1.0.0 googleapis-common-protos==1.52.0 grpcio==1.31.0 -html5lib==1.0.1 httplib2==0.18.1 idna==2.10 iniconfig==1.0.1 injectark==0.4.1 -ipaddr==2.2.0 Jinja2==2.11.2 -lazy-object-proxy==1.4.2 -lockfile==0.12.2 MarkupSafe==1.1.1 marshmallow==3.7.1 migrark==0.6.0 -mock==3.0.5 -modelark==0.2.3 +modelark==0.2.7 + more-itertools==8.5.0 msgpack==1.0.0 multidict==4.7.6 packaging==20.4 -pep517==0.8.2 +pgdb==0.0.8 pluggy==0.13.1 -progress==1.5 protobuf==3.13.0 py==1.9.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 -pycodestyle==2.5.0 +pycodestyle==2.6.0 pycparser==2.20 PyGreSQL==5.2 pyparsing==2.4.7 pytest==6.0.1 pytest-aiohttp==0.3.0 pytest-asyncio==0.14.0 +pytest-clarity==0.3.0a0 pytest-cov==2.10.1 -pytoml==0.1.21 pytz==2020.1 -PyYAML==5.1.2 -rapidjson==1.0.0 requests==2.24.0 -retrying==1.3.3 rsa==4.6 six==1.15.0 tenark==0.8.3 +termcolor==1.1.0 toml==0.10.1 -typed-ast==1.4.0 uritemplate==3.0.1 urllib3==1.25.10 uvloop==0.14.0 -webencodings==0.5.1 -wrapt==1.11.2 +wcwidth==0.2.5 +widark==0.3.3 yarl==1.5.1