mirror of
				https://github.com/chartdb/chartdb.git
				synced 2025-11-04 05:53:15 +00:00 
			
		
		
		
	feat(custom-types): add enums and composite types for Postgres (#714)
* feat(postgres): add custom datatypes to import script * import only enums & composite types * init commit to support custom types in postgres * add support in matching custom fields on import + be able to choose it as type for feild * update select box + type names * all but ui * update ui * fix build * fix build * fix --------- Co-authored-by: Guy Ben-Aharon <baguy3@gmail.com>
This commit is contained in:
		@@ -11,6 +11,7 @@ import type { DBSchema } from '@/lib/domain/db-schema';
 | 
			
		||||
import type { DBDependency } from '@/lib/domain/db-dependency';
 | 
			
		||||
import { EventEmitter } from 'ahooks/lib/useEventEmitter';
 | 
			
		||||
import type { Area } from '@/lib/domain/area';
 | 
			
		||||
import type { DBCustomType } from '@/lib/domain/db-custom-type';
 | 
			
		||||
 | 
			
		||||
export type ChartDBEventType =
 | 
			
		||||
    | 'add_tables'
 | 
			
		||||
@@ -72,6 +73,7 @@ export interface ChartDBContext {
 | 
			
		||||
    relationships: DBRelationship[];
 | 
			
		||||
    dependencies: DBDependency[];
 | 
			
		||||
    areas: Area[];
 | 
			
		||||
    customTypes: DBCustomType[];
 | 
			
		||||
    currentDiagram: Diagram;
 | 
			
		||||
    events: EventEmitter<ChartDBEvent>;
 | 
			
		||||
    readonly?: boolean;
 | 
			
		||||
@@ -248,6 +250,33 @@ export interface ChartDBContext {
 | 
			
		||||
        area: Partial<Area>,
 | 
			
		||||
        options?: { updateHistory: boolean }
 | 
			
		||||
    ) => Promise<void>;
 | 
			
		||||
 | 
			
		||||
    // Custom type operations
 | 
			
		||||
    createCustomType: (
 | 
			
		||||
        attributes?: Partial<Omit<DBCustomType, 'id'>>
 | 
			
		||||
    ) => Promise<DBCustomType>;
 | 
			
		||||
    addCustomType: (
 | 
			
		||||
        customType: DBCustomType,
 | 
			
		||||
        options?: { updateHistory: boolean }
 | 
			
		||||
    ) => Promise<void>;
 | 
			
		||||
    addCustomTypes: (
 | 
			
		||||
        customTypes: DBCustomType[],
 | 
			
		||||
        options?: { updateHistory: boolean }
 | 
			
		||||
    ) => Promise<void>;
 | 
			
		||||
    getCustomType: (id: string) => DBCustomType | null;
 | 
			
		||||
    removeCustomType: (
 | 
			
		||||
        id: string,
 | 
			
		||||
        options?: { updateHistory: boolean }
 | 
			
		||||
    ) => Promise<void>;
 | 
			
		||||
    removeCustomTypes: (
 | 
			
		||||
        ids: string[],
 | 
			
		||||
        options?: { updateHistory: boolean }
 | 
			
		||||
    ) => Promise<void>;
 | 
			
		||||
    updateCustomType: (
 | 
			
		||||
        id: string,
 | 
			
		||||
        customType: Partial<DBCustomType>,
 | 
			
		||||
        options?: { updateHistory: boolean }
 | 
			
		||||
    ) => Promise<void>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const chartDBContext = createContext<ChartDBContext>({
 | 
			
		||||
@@ -258,6 +287,7 @@ export const chartDBContext = createContext<ChartDBContext>({
 | 
			
		||||
    relationships: [],
 | 
			
		||||
    dependencies: [],
 | 
			
		||||
    areas: [],
 | 
			
		||||
    customTypes: [],
 | 
			
		||||
    schemas: [],
 | 
			
		||||
    filteredSchemas: [],
 | 
			
		||||
    filterSchemas: emptyFn,
 | 
			
		||||
@@ -333,4 +363,13 @@ export const chartDBContext = createContext<ChartDBContext>({
 | 
			
		||||
    removeArea: emptyFn,
 | 
			
		||||
    removeAreas: emptyFn,
 | 
			
		||||
    updateArea: emptyFn,
 | 
			
		||||
 | 
			
		||||
    // Custom type operations
 | 
			
		||||
    createCustomType: emptyFn,
 | 
			
		||||
    addCustomType: emptyFn,
 | 
			
		||||
    addCustomTypes: emptyFn,
 | 
			
		||||
    getCustomType: emptyFn,
 | 
			
		||||
    removeCustomType: emptyFn,
 | 
			
		||||
    removeCustomTypes: emptyFn,
 | 
			
		||||
    updateCustomType: emptyFn,
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user