mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix(plugin-file-manager): fix migration for inherited collection (#6310)
This commit is contained in:
parent
414ec3c817
commit
22869ca184
@ -65,6 +65,10 @@ export class InheritedCollection extends Collection {
|
|||||||
parentFields() {
|
parentFields() {
|
||||||
const fields = new Map<string, Field>();
|
const fields = new Map<string, Field>();
|
||||||
|
|
||||||
|
if (!this.parents) {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
for (const parent of this.parents) {
|
for (const parent of this.parents) {
|
||||||
if (parent.isInherited()) {
|
if (parent.isInherited()) {
|
||||||
for (const [name, field] of (<InheritedCollection>parent).parentFields()) {
|
for (const [name, field] of (<InheritedCollection>parent).parentFields()) {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
import { DataTypes } from 'sequelize';
|
import { DataTypes } from 'sequelize';
|
||||||
import { Migration } from '@nocobase/server';
|
import { Migration } from '@nocobase/server';
|
||||||
import { CollectionRepository } from '@nocobase/plugin-data-source-main';
|
import { CollectionRepository } from '@nocobase/plugin-data-source-main';
|
||||||
|
import { InheritedCollection } from '@nocobase/database';
|
||||||
|
|
||||||
export default class extends Migration {
|
export default class extends Migration {
|
||||||
on = 'afterLoad'; // 'beforeLoad' or 'afterLoad'
|
on = 'afterLoad'; // 'beforeLoad' or 'afterLoad'
|
||||||
@ -31,23 +32,25 @@ export default class extends Migration {
|
|||||||
|
|
||||||
await this.db.sequelize.transaction(async (transaction) => {
|
await this.db.sequelize.transaction(async (transaction) => {
|
||||||
for (const collection of collections) {
|
for (const collection of collections) {
|
||||||
const tableName = collection.getTableNameWithSchema();
|
if (!(collection instanceof InheritedCollection)) {
|
||||||
await queryInterface.changeColumn(
|
const tableName = collection.getTableNameWithSchema();
|
||||||
tableName,
|
await queryInterface.changeColumn(
|
||||||
'url',
|
tableName,
|
||||||
{
|
'url',
|
||||||
type: DataTypes.TEXT,
|
{
|
||||||
},
|
type: DataTypes.TEXT,
|
||||||
{ transaction },
|
},
|
||||||
);
|
{ transaction },
|
||||||
await queryInterface.changeColumn(
|
);
|
||||||
tableName,
|
await queryInterface.changeColumn(
|
||||||
'path',
|
tableName,
|
||||||
{
|
'path',
|
||||||
type: DataTypes.TEXT,
|
{
|
||||||
},
|
type: DataTypes.TEXT,
|
||||||
{ transaction },
|
},
|
||||||
);
|
{ transaction },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await FieldRepo.update({
|
await FieldRepo.update({
|
||||||
filter: {
|
filter: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user