Merge pull request #577 from outline/revert-573-jori/rename-atlasid
Revert "Renamed Document#atlasId finally"
This commit is contained in:
commit
872ca56d99
|
@ -20,7 +20,7 @@ router.post('documents.list', auth(), pagination(), async ctx => {
|
|||
|
||||
const user = ctx.state.user;
|
||||
let where = { teamId: user.teamId };
|
||||
if (collection) where = { ...where, collectionId: collection };
|
||||
if (collection) where = { ...where, atlasId: collection };
|
||||
|
||||
const userId = user.id;
|
||||
const starredScope = { method: ['withStarred', userId] };
|
||||
|
@ -215,7 +215,7 @@ router.post('documents.create', auth(), async ctx => {
|
|||
parentDocumentObj = await Document.findOne({
|
||||
where: {
|
||||
id: parentDocument,
|
||||
collectionId: ownerCollection.id,
|
||||
atlasId: ownerCollection.id,
|
||||
},
|
||||
});
|
||||
if (!parentDocumentObj)
|
||||
|
@ -224,7 +224,7 @@ router.post('documents.create', auth(), async ctx => {
|
|||
|
||||
const newDocument = await Document.create({
|
||||
parentDocumentId: parentDocumentObj.id,
|
||||
collectionId: ownerCollection.id,
|
||||
atlasId: ownerCollection.id,
|
||||
teamId: user.teamId,
|
||||
userId: user.id,
|
||||
lastModifiedById: user.id,
|
||||
|
@ -287,7 +287,7 @@ router.post('documents.move', auth(), async ctx => {
|
|||
if (index) ctx.assertPositiveInteger(index, 'index must be an integer (>=0)');
|
||||
|
||||
const document = await Document.findById(id);
|
||||
const collection = await Collection.findById(document.collectionId);
|
||||
const collection = await Collection.findById(document.atlasId);
|
||||
|
||||
authDocumentForUser(ctx, document);
|
||||
|
||||
|
@ -297,7 +297,7 @@ router.post('documents.move', auth(), async ctx => {
|
|||
// Set parent document
|
||||
if (parentDocument) {
|
||||
const parent = await Document.findById(parentDocument);
|
||||
if (!parent || parent.collectionId !== document.collectionId)
|
||||
if (!parent || parent.atlasId !== document.atlasId)
|
||||
throw httpErrors.BadRequest(
|
||||
'Invalid parentDocument (must be same collection)'
|
||||
);
|
||||
|
@ -324,7 +324,7 @@ router.post('documents.delete', auth(), async ctx => {
|
|||
ctx.assertPresent(id, 'id is required');
|
||||
|
||||
const document = await Document.findById(id);
|
||||
const collection = await Collection.findById(document.collectionId);
|
||||
const collection = await Collection.findById(document.atlasId);
|
||||
|
||||
authDocumentForUser(ctx, document);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('#documents.list', async () => {
|
|||
it('should allow filtering by collection', async () => {
|
||||
const { user, document } = await seed();
|
||||
const res = await server.post('/api/documents.list', {
|
||||
body: { token: user.getJwtToken(), collection: document.collectionId },
|
||||
body: { token: user.getJwtToken(), collection: document.atlasId },
|
||||
});
|
||||
const body = await res.json();
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.renameColumn('documents', 'atlasId', 'collectionId');
|
||||
},
|
||||
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.renameColumn('documents', 'collectionId', 'atlasId');
|
||||
},
|
||||
};
|
|
@ -53,7 +53,7 @@ const Collection = sequelize.define(
|
|||
// Create intro document if first collection for team
|
||||
const document = await Document.create({
|
||||
parentDocumentId: null,
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
teamId: collection.teamId,
|
||||
userId: collection.creatorId,
|
||||
lastModifiedById: collection.creatorId,
|
||||
|
@ -77,7 +77,7 @@ const Collection = sequelize.define(
|
|||
Collection.associate = models => {
|
||||
Collection.hasMany(models.Document, {
|
||||
as: 'documents',
|
||||
foreignKey: 'collectionId',
|
||||
foreignKey: 'atlasId',
|
||||
onDelete: 'cascade',
|
||||
});
|
||||
Collection.belongsTo(models.Team, {
|
||||
|
@ -98,7 +98,7 @@ Collection.associate = models => {
|
|||
Collection.addHook('afterDestroy', async model => {
|
||||
await Document.destroy({
|
||||
where: {
|
||||
collectionId: model.id,
|
||||
atlasId: model.id,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
@ -119,7 +119,7 @@ describe('#updateDocument', () => {
|
|||
// Add a child for testing
|
||||
const newDocument = await Document.create({
|
||||
parentDocumentId: document.id,
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
teamId: collection.teamId,
|
||||
userId: collection.creatorId,
|
||||
lastModifiedById: collection.creatorId,
|
||||
|
@ -155,7 +155,7 @@ describe('#moveDocument', () => {
|
|||
// Add a child for testing
|
||||
const newDocument = await Document.create({
|
||||
parentDocumentId: document.id,
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
teamId: collection.teamId,
|
||||
userId: collection.creatorId,
|
||||
lastModifiedById: collection.creatorId,
|
||||
|
@ -190,7 +190,7 @@ describe('#removeDocument', () => {
|
|||
// Verify that the document was removed
|
||||
const collectionDocuments = await Document.findAndCountAll({
|
||||
where: {
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
},
|
||||
});
|
||||
expect(collectionDocuments.count).toBe(1);
|
||||
|
@ -202,7 +202,7 @@ describe('#removeDocument', () => {
|
|||
// Add a child for testing
|
||||
const newDocument = await Document.create({
|
||||
parentDocumentId: document.id,
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
teamId: collection.teamId,
|
||||
userId: collection.creatorId,
|
||||
lastModifiedById: collection.creatorId,
|
||||
|
@ -218,7 +218,7 @@ describe('#removeDocument', () => {
|
|||
expect(collection.documentStructure.length).toBe(1);
|
||||
const collectionDocuments = await Document.findAndCountAll({
|
||||
where: {
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
},
|
||||
});
|
||||
expect(collectionDocuments.count).toBe(1);
|
||||
|
@ -230,7 +230,7 @@ describe('#removeDocument', () => {
|
|||
// Add a child for testing
|
||||
const newDocument = await Document.create({
|
||||
parentDocumentId: document.id,
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
teamId: collection.teamId,
|
||||
userId: collection.creatorId,
|
||||
lastModifiedById: collection.creatorId,
|
||||
|
@ -251,7 +251,7 @@ describe('#removeDocument', () => {
|
|||
|
||||
const collectionDocuments = await Document.findAndCountAll({
|
||||
where: {
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
},
|
||||
});
|
||||
expect(collectionDocuments.count).toBe(2);
|
||||
|
|
|
@ -116,7 +116,7 @@ const Document = sequelize.define(
|
|||
Document.associate = models => {
|
||||
Document.belongsTo(models.Collection, {
|
||||
as: 'collection',
|
||||
foreignKey: 'collectionId',
|
||||
foreignKey: 'atlasId',
|
||||
onDelete: 'cascade',
|
||||
});
|
||||
Document.belongsTo(models.User, {
|
||||
|
|
|
@ -39,7 +39,7 @@ async function present(ctx: Object, document: Document, options: ?Options) {
|
|||
collaborators: [],
|
||||
starred: !!(document.starred && document.starred.length),
|
||||
revision: document.revisionCount,
|
||||
collectionId: document.collectionId,
|
||||
collectionId: document.atlasId,
|
||||
collaboratorCount: undefined,
|
||||
collection: undefined,
|
||||
views: undefined,
|
||||
|
|
|
@ -62,7 +62,7 @@ const seed = async () => {
|
|||
|
||||
const document = await Document.create({
|
||||
parentDocumentId: null,
|
||||
collectionId: collection.id,
|
||||
atlasId: collection.id,
|
||||
teamId: team.id,
|
||||
userId: collection.creatorId,
|
||||
lastModifiedById: collection.creatorId,
|
||||
|
|
Reference in New Issue