Commit 9e2e2232 authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

schema: rename `tsh-automatic` to `tsh-upstream`

parent b6c993936bc2
......@@ -19,7 +19,7 @@ def engine(request):
db.setup_local_pg_cluster(request, DATADIR, port)
uri = 'postgresql://localhost:{}/postgres'.format(port)
sch1 = tsschema()
sch2 = tsschema('tsh-automatic')
sch2 = tsschema('tsh-upstream')
e = create_engine(uri)
sch1.create(e)
sch2.create(e)
......
......@@ -12,6 +12,9 @@ setup(name='tshistory_supervision',
install_requires=[
'tshistory'
],
entry_points={'tshistory.subcommands': [
'migrate-supervision=tshistory_supervision.cli:migrate_supervision'
]},
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
......
import click
from sqlalchemy import create_engine
from tshistory.util import find_dburi
@click.command(name='migrate-supervision')
@click.argument('dburi')
@click.option('--namespace', default='tsh')
def migrate_supervision(dburi, skip_schema=False, namespace='tsh'):
engine = create_engine(find_dburi(dburi))
with engine.begin() as cn:
cn.execute(
f'alter schema "{namespace}-automatic" '
f'rename to "{namespace}-upstream"'
)
cn.execute(
f'alter schema "{namespace}-automatic.timeserie" '
f'rename to "{namespace}-upstream.timeserie"'
)
cn.execute(
f'alter schema "{namespace}-automatic.snapshot" '
f'rename to "{namespace}-upstream.snapshot"'
)
......@@ -55,7 +55,7 @@ class timeseries(basets):
def __init__(self, *a, **kw):
super().__init__(*a, **kw)
self.upstream = basets(namespace='{}-automatic'.format(self.namespace))
self.upstream = basets(namespace='{}-upstream'.format(self.namespace))
@tx
def insert(self, cn, ts, name, author,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment