mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
update communities table for home-community entries
This commit is contained in:
parent
9879df4eb5
commit
7c73dde06c
51
database/entity/0060-update_communities_table/Community.ts
Normal file
51
database/entity/0060-update_communities_table/Community.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import {
|
||||
BaseEntity,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
|
||||
@Entity('communities')
|
||||
export class Community extends BaseEntity {
|
||||
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||
id: number
|
||||
|
||||
@Column({ name: 'foreign', type: 'bool', nullable: false, default: true })
|
||||
foreign: boolean
|
||||
|
||||
@Column({ name: 'public_key', type: 'binary', length: 64, default: null, nullable: true })
|
||||
publicKey: Buffer
|
||||
|
||||
@Column({ name: 'api_version', length: 10, nullable: false })
|
||||
apiVersion: string
|
||||
|
||||
@Column({ name: 'end_point', length: 255, nullable: false })
|
||||
endPoint: string
|
||||
|
||||
@Column({ name: 'last_announced_at', type: 'datetime', nullable: true })
|
||||
lastAnnouncedAt: Date
|
||||
|
||||
@Column({ name: 'verified_at', type: 'datetime', nullable: true })
|
||||
verifiedAt: Date
|
||||
|
||||
@Column({ name: 'last_error_at', type: 'datetime', nullable: true })
|
||||
lastErrorAt: Date
|
||||
|
||||
@CreateDateColumn({
|
||||
name: 'created_at',
|
||||
type: 'datetime',
|
||||
default: () => 'CURRENT_TIMESTAMP(3)',
|
||||
nullable: false,
|
||||
})
|
||||
createdAt: Date
|
||||
|
||||
@UpdateDateColumn({
|
||||
name: 'updated_at',
|
||||
type: 'datetime',
|
||||
onUpdate: 'CURRENT_TIMESTAMP(3)',
|
||||
nullable: true,
|
||||
})
|
||||
updatedAt: Date | null
|
||||
}
|
||||
@ -1 +1 @@
|
||||
export { Community } from './0058-add_communities_table/Community'
|
||||
export { Community } from './0060-update_communities_table/Community'
|
||||
|
||||
32
database/migrations/0060-update_communities_table.ts
Normal file
32
database/migrations/0060-update_communities_table.ts
Normal file
@ -0,0 +1,32 @@
|
||||
/* MIGRATION TO CREATE THE FEDERATION COMMUNITY TABLES
|
||||
*
|
||||
* This migration creates the `community` and 'communityfederation' tables in the `apollo` database (`gradido_community`).
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn(
|
||||
'ALTER TABLE `communities` MODIFY COLUMN `last_announced_at` datetime(3) AFTER `end_point`;',
|
||||
)
|
||||
await queryFn(
|
||||
'ALTER TABLE `communities` ADD COLUMN `foreign` tinyint(4) NOT NULL DEFAULT 1 AFTER `id`;',
|
||||
)
|
||||
await queryFn(
|
||||
'ALTER TABLE `communities` ADD COLUMN `verified_at` datetime(3) AFTER `last_announced_at`;',
|
||||
)
|
||||
await queryFn(
|
||||
'ALTER TABLE `communities` ADD COLUMN `last_error_at` datetime(3) AFTER `verified_at`;',
|
||||
)
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
// write downgrade logic as parameter of queryFn
|
||||
await queryFn(
|
||||
'ALTER TABLE `communities` MODIFY COLUMN `last_announced_at` datetime(3) NOT NULL AFTER `end_point`;',
|
||||
)
|
||||
await queryFn('ALTER TABLE communities DROP COLUMN foreign;')
|
||||
await queryFn('ALTER TABLE communities DROP COLUMN verified_at;')
|
||||
await queryFn('ALTER TABLE communities DROP COLUMN last_error_at;')
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user