import { GraphQLModelsType, GraphQLRelationsType } from '@subql/utils'; import { IndexesOptions, Model, ModelAttributeColumnOptions, ModelAttributes, ModelStatic, Sequelize } from '@subql/x-sequelize'; import { ModelIndexesOptions } from '@subql/x-sequelize/types/model'; import { EnumType } from '../utils'; export type Query = { sql: string; replacements?: any[]; }; /** * @deprecated use Query instead for increased security * */ export type QueryString = Query | string; export declare function isQuery(input: QueryString): input is Query; export interface SmartTags { foreignKey?: string; foreignFieldName?: string; singleForeignFieldName?: string; } export interface NotifyTriggerPayload { triggerName: string; eventManipulation: string; } export declare function smartTags(tags: SmartTags, separator?: string): string; export declare function getVirtualFkTag(field: string, to: string): string; export declare const underscored: (input: string) => string; export declare function getFkConstraint(tableName: string, foreignKey: string): string; export declare function getUniqConstraint(tableName: string, field: string): string; export declare function commentConstraintQuery(schema: string, table: string, constraint: string, comment: string): Query; export declare function commentTableQuery(schema: string, table: string, comment: string): Query; export declare function commentColumnQuery(schema: string, table: string, column: string, comment: string): Query; export declare function commentOnFunction(schema: string, functionName: string, comment: string): Query; export declare function constraintDeferrableQuery(table: string, constraint: string): string; export declare function addTagsToForeignKeyMap(map: Map>, tableName: string, foreignKey: string, newTags: SmartTags): void; export declare const BTREE_GIST_EXTENSION_EXIST_QUERY = "SELECT * FROM pg_extension where extname = 'btree_gist'"; export declare function createUniqueIndexQuery(schema: string, table: string, field: string): string; export declare function getTriggers(sequelize: Sequelize, triggerName: string): Promise; export declare function getFunctions(sequelize: Sequelize, schema: string, functionName: string): Promise; export declare function createSendNotificationTriggerFunction(schema: string): string; export declare function createNotifyTrigger(schema: string, table: string): string; export declare function dropNotifyTrigger(schema: string, table: string): string; export declare function dropNotifyFunction(schema: string): string; export declare function createSchemaTrigger(schema: string, metadataTableName: string): string; export declare function createSchemaTriggerFunction(schema: string): string; export declare function createRewindTrigger(schema: string): string; export declare function createRewindTriggerFunction(schema: string): string; export declare function getExistedIndexesQuery(schema: string): string; export declare function getDbSizeAndUpdateMetadata(sequelize: Sequelize, schema: string): Promise; /** * Improve SQL which could potentially increase DB IO significantly, * this executes it by batch size, and in ASC id order **/ export declare const sqlIterator: (tableName: string, sql: string, batch?: number) => string; export declare function addHistoricalIdIndex(model: GraphQLModelsType, indexes: IndexesOptions[]): void; export declare function generateHashedIndexName(modelName: string, indexOptions: IndexesOptions): string; export declare function updateIndexesName(modelName: string, indexes: IndexesOptions[], existedIndexes: string[]): void; export declare function addIdAndBlockRangeAttributes(attributes: ModelAttributes, any>): void; export declare function addBlockRangeColumnToIndexes(indexes: IndexesOptions[]): void; export declare function addRelationToMap(relation: GraphQLRelationsType, foreignKeys: Map>, model: ModelStatic, relatedModel: ModelStatic): void; export declare function generateCreateTableQuery(model: ModelStatic>, schema: string, withoutForeignKey: boolean): QueryString[]; export declare function generateCreateIndexQuery(indexes: readonly ModelIndexesOptions[], schema: string, tableName: string): string[]; export declare function sortModels(relations: GraphQLRelationsType[], models: GraphQLModelsType[]): GraphQLModelsType[] | null; export declare function validateNotifyTriggers(triggerName: string, triggers: NotifyTriggerPayload[]): void; export declare function getExistingForeignKeys(schema: string, sequelize: Sequelize): Promise; export declare function getExistingEnums(schema: string, sequelize: Sequelize): Promise>; export declare const dropEnumQuery: (enumTypeValue: string, schema: string) => string; export declare const commentOnEnumQuery: (type: string, comment: string) => string; export declare const createEnumQuery: (type: string, enumValues: string) => string; export declare const addEnumValueQuery: (type: string, newValue: string) => string; export declare const dropRelationQuery: (schemaName: string, tableName: string, fkConstraint: string) => string; export declare function generateForeignKeyQuery(attribute: ModelAttributeColumnOptions, tableName: string): string | void; export declare const dropIndexQuery: (schema: string, hashedIndexName: string) => string; export declare const createIndexQuery: (indexOptions: IndexesOptions, tableName: string, schema: string) => string; export declare const dropColumnQuery: (schema: string, columnName: string, tableName: string) => string; export declare const createColumnQuery: (schema: string, table: string, columnName: string, attributes: string) => string; export declare const dropTsVectorColumnQuery: (schema: string, table: string) => string; export declare const createTsVectorColumnQuery: (schema: string, table: string, fields: string[], language?: string) => string; export declare const createTsVectorCommentQuery: (schema: string, table: string) => Query; export declare const dropTsVectorIndexQuery: (schema: string, table: string) => string; export declare const createTsVectorIndexQuery: (schema: string, table: string) => string; export declare const dropSearchFunctionQuery: (schema: string, table: string) => string; export declare const createSearchFunctionQuery: (schema: string, table: string) => string; export declare const commentSearchFunctionQuery: (schema: string, table: string) => Query; export declare const tableExistsQuery: (schema: string) => string;