fix(collection-manager): update timestamps to true

This commit is contained in:
chenos 2022-12-21 10:01:39 +08:00
parent d7ec5d547e
commit 1868a8a5f3
3 changed files with 25 additions and 2 deletions

View File

@ -143,7 +143,7 @@ export function afterCreateForForeignKeyField(db: Database) {
values: {
name: through,
title: through,
timestamps: false,
timestamps: true,
autoGenId: false,
hidden: true,
autoCreate: true,

View File

@ -0,0 +1,23 @@
import { Migration } from '@nocobase/server';
export default class extends Migration {
async up() {
const result = await this.app.version.satisfies('<=0.8.0-alpha.13');
if (!result) {
return;
}
try {
const collections = await this.app.db.getRepository('collections').find();
console.log('migrating...');
for (const collection of collections) {
if (collection.get('autoCreate') && collection.get('isThrough')) {
collection.set('timestamps', true);
await collection.save();
console.log(`collection name: ${collection.name}`);
}
}
} catch (error) {
console.error(error);
}
}
}

View File

@ -1,6 +1,6 @@
import Topo from '@hapi/topo';
import { Model, Repository } from '@nocobase/database';
import { CollectionModel } from '../models/collection';
import Topo from '@hapi/topo';
interface LoadOptions {
filter?: any;