diff --git a/migrations/20201028052525-volumes-create-table.js b/migrations/20201028052525-volumes-create-table.js index d8c2ed5ce..245d98b41 100644 --- a/migrations/20201028052525-volumes-create-table.js +++ b/migrations/20201028052525-volumes-create-table.js @@ -12,6 +12,7 @@ exports.up = function(db, callback) { 'appId VARCHAR(128) NOT NULL,' + 'volumeId VARCHAR(128) NOT NULL,' + 'readOnly BOOLEAN DEFAULT 1,' + + 'UNIQUE KEY appMounts_appId_volumeId (appId, volumeId),' + 'FOREIGN KEY(appId) REFERENCES apps(id),' + 'FOREIGN KEY(volumeId) REFERENCES volumes(id)) CHARACTER SET utf8 COLLATE utf8_bin;'; diff --git a/migrations/schema.sql b/migrations/schema.sql index ae9fb9c36..cd56350b6 100644 --- a/migrations/schema.sql +++ b/migrations/schema.sql @@ -85,7 +85,6 @@ CREATE TABLE IF NOT EXISTS apps( dataDir VARCHAR(256) UNIQUE, taskId INTEGER, // current task errorJson TEXT, - bindsJson TEXT, // bind mounts servicesConfigJson TEXT, // app services configuration FOREIGN KEY(mailboxDomain) REFERENCES domains(domain), @@ -248,6 +247,8 @@ CREATE TABLE IF NOT EXISTS volumes( CREATE TABLE IF NOT EXISTS appMounts( appId VARCHAR(128) NOT NULL, volumeId VARCHAR(128) NOT NULL, + readOnly BOOLEAN DEFAULT 1, + UNIQUE KEY appMounts_appId_volumeId (appId, volumeId), FOREIGN KEY(appId) REFERENCES apps(id), FOREIGN KEY(volumeId) REFERENCES volumes(id)); diff --git a/src/apps.js b/src/apps.js index 46a0abc6d..b78a10622 100644 --- a/src/apps.js +++ b/src/apps.js @@ -995,6 +995,7 @@ function setMounts(app, mounts, auditSource, callback) { values: { mounts } }; addTask(appId, exports.ISTATE_PENDING_RECREATE_CONTAINER, task, function (error, result) { + if (error && error.reason === BoxError.ALREADY_EXISTS) return callback(new BoxError(BoxError.CONFLICT, 'Duplicate mount points')); if (error) return callback(error); eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId, app, mounts, taskId: result.taskId });