Commit a0ecda20 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

rename tables ad dj_*

parent 880e1e2a
......@@ -714,7 +714,7 @@ exec /.toolbox/bin/sshd -D
with ses.begin():
# put all candidates in 'error state'
if recover:
ses.execute('''UPDATE webapp_versions
ses.execute('''UPDATE dj_webapp_versions
SET changelog=CONCAT(changelog, " [", :changelog, "]"), state=:state
WHERE id IN :ids''', dict(changelog=changelog, ids=recover,
state=int(VersionState.ERROR)))
......@@ -757,7 +757,7 @@ exec /.toolbox/bin/sshd -D
log.error("%s", error)
next_state = VersionState.ERROR
image_size = 0
ses.execute('''UPDATE webapp_versions
ses.execute('''UPDATE dj_webapp_versions
SET changelog=CONCAT(changelog, " [commit error: sandbox is down]")
WHERE id=%d''' % version.id)
......@@ -782,7 +782,7 @@ exec /.toolbox/bin/sshd -D
#
if next_state is not None:
with ses.begin():
ses.execute("UPDATE webapp_versions SET state=%d, docker_image_size=%d WHERE id=%d"
ses.execute("UPDATE dj_webapp_versions SET state=%d, docker_image_size=%d WHERE id=%d"
% (next_state, image_size, version.id))
......@@ -913,7 +913,7 @@ exec /.toolbox/bin/sshd -D
# stops the sandbox while it is not fully started)
log.info("sandbox %r is now in state %r", webapp.docker_name, next_state.name)
with ses.begin():
ses.execute("UPDATE webapps SET sandbox_state=%d WHERE id=%d AND sandbox_state=%d" %
ses.execute("UPDATE dj_webapps SET sandbox_state=%d WHERE id=%d AND sandbox_state=%d" %
(next_state, webapp_id, webapp.sandbox_state))
log.debug("done sandbox %d", webapp_id)
......@@ -1180,7 +1180,7 @@ class JobManager(Manager):
if result is not None:
ses = self.ctrl.session
with ses.begin():
ses.execute("UPDATE jobs SET result=%d WHERE id=%d AND result=%d" %
ses.execute("UPDATE dj_jobs SET result=%d WHERE id=%d AND result=%d" %
(int(result), info.job_id, int(JobResult.NONE)))
# remove container
......@@ -1661,17 +1661,17 @@ class DockerController:
ses = self.session
with ses.begin():
if startup:
ses.execute("DELETE FROM webapp_versions WHERE state=%d"
ses.execute("DELETE FROM dj_webapp_versions WHERE state=%d"
% VersionState.REPLACED)
for version_id, in ses.execute(
"SELECT id FROM webapp_versions WHERE state=%d"
"SELECT id FROM dj_webapp_versions WHERE state=%d"
% VersionState.COMMITTED).fetchall():
self.image_manager.push(version_id)
for webapp_id, in ses.execute("""SELECT webapps.id FROM webapps
LEFT JOIN webapp_versions ON webapps.id=webapp_versions.webapp_id
for webapp_id, in ses.execute("""SELECT dj_webapps.id FROM dj_webapps
LEFT JOIN dj_webapp_versions ON dj_webapps.id=dj_webapp_versions.webapp_id
WHERE sandbox_state IN (%d,%d) OR state=%d
GROUP BY webapps.id""" % (
GROUP BY dj_webapps.id""" % (
SandboxState.STARTING, SandboxState.STOPPING, VersionState.SANDBOX)).fetchall():
self.sandbox_manager.process(webapp_id)
......
......@@ -46,13 +46,13 @@ class JobResult(enum.IntEnum):
class Webapp(Base):
__tablename__ = "webapps"
__tablename__ = "dj_webapps"
id = Column(Integer, primary_key=True)
docker_name = Column(String)
sandbox_state = Column(Integer)
sandbox_version_id = Column(Integer, ForeignKey('webapp_versions.id'))
docker_os_id = Column(Integer, ForeignKey('docker_os.id'))
sandbox_version_id = Column(Integer, ForeignKey('dj_webapp_versions.id'))
docker_os_id = Column(Integer, ForeignKey('dj_docker_os.id'))
exec_time = Column(Integer)
entrypoint = Column(String)
memory_limit = Column(Integer)
......@@ -72,10 +72,10 @@ class Webapp(Base):
super().__setattr__(key, value)
class WebappVersion(Base):
__tablename__ = "webapp_versions"
__tablename__ = "dj_webapp_versions"
id = Column(Integer, primary_key=True)
webapp_id = Column(Integer, ForeignKey('webapps.id'))
webapp_id = Column(Integer, ForeignKey('dj_webapps.id'))
created_at = Column(DateTime, default=datetime.datetime.now)
updated_at = Column(DateTime, default=datetime.datetime.now)
number = Column(String)
......@@ -91,7 +91,7 @@ class WebappVersion(Base):
super().__setattr__(key, value)
class DockerOs(Base):
__tablename__ = "docker_os"
__tablename__ = "dj_docker_os"
id = Column(Integer, primary_key=True)
docker_name = Column(String)
......@@ -103,17 +103,17 @@ class DockerOs(Base):
"id", "docker_name", "version"))))
class JobQueue(Base):
__tablename__ = "job_queues"
__tablename__ = "dj_job_queues"
id = Column(Integer, primary_key=True)
name = Column(String)
timeout = Column(Integer)
class Job(Base):
__tablename__ = "jobs"
__tablename__ = "dj_jobs"
id = Column(Integer, primary_key=True)
webapp_id = Column(Integer, ForeignKey('webapps.id'))
webapp_id = Column(Integer, ForeignKey('dj_webapps.id'))
user_id = Column(Integer)
state = Column(Integer)
result = Column(Integer)
......@@ -122,7 +122,7 @@ class Job(Base):
exec_time = Column(Integer)
access_token = Column(String)
container_id = Column(String(64))
queue_id = Column(Integer, ForeignKey('job_queues.id'))
queue_id = Column(Integer, ForeignKey('dj_job_queues.id'))
webapp = relationship("Webapp")
......
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