mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix: relations media links with models.
This commit is contained in:
@@ -3,7 +3,7 @@ exports.up = function(knex) {
|
||||
return knex.schema.createTable('media_links', table => {
|
||||
table.increments();
|
||||
table.string('model_name').index();
|
||||
table.integer('media_id').unsigned().index();
|
||||
table.integer('media_id').unsigned().references('id').inTable('media');
|
||||
table.integer('model_id').unsigned().index();
|
||||
})
|
||||
};
|
||||
|
||||
@@ -103,6 +103,9 @@ export default class Expense extends TenantModel {
|
||||
},
|
||||
to: 'media.id',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('model_name', 'Expense');
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ export default class ManualJournal extends TenantModel {
|
||||
to: 'media_links.media_id',
|
||||
},
|
||||
to: 'media.id',
|
||||
},
|
||||
filter(query) {
|
||||
query.where('model_name', 'ManualJournal');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user