import { O_CREATE_TABLE_CREATE_DEFINITION, P_CREATE_INDEX, O_CREATE_TABLE_CREATE_DEFINITION_UNIQUE_KEY, O_ALTER_TABLE_SPEC_ADD_UNIQUE_KEY, UniqueKeyInterface } from '../../../../typings'; import { UniqueKeyModelInterface, IndexColumnModelInterface, IndexOptionsModelInterface, TableModelInterface, ColumnModelInterface } from './typings'; /** * Unique key of a table. */ export declare class UniqueKey implements UniqueKeyModelInterface { name?: string; indexType?: string; columns: IndexColumnModelInterface[]; options?: IndexOptionsModelInterface; /** * Creates a unique key from a JSON def. * * @param json JSON format parsed from SQL. */ static fromDef(json: O_CREATE_TABLE_CREATE_DEFINITION | P_CREATE_INDEX): UniqueKey; /** * Creates an unique key from an object containing needed properties. * * @param json Object containing properties. */ static fromObject(json: P_CREATE_INDEX['def'] | O_CREATE_TABLE_CREATE_DEFINITION_UNIQUE_KEY | O_ALTER_TABLE_SPEC_ADD_UNIQUE_KEY): UniqueKey; /** * JSON casting of this object calls this method. */ toJSON(): UniqueKeyInterface; /** * Create a deep clone of this model. */ clone(): UniqueKey; /** * Drops a column from key. Returns whether column was removed. * * @param name Column name to be dropped. */ dropColumn(name: string): boolean; /** * Get the columns in given table which this * unique key's index columns refer to. * * @param table Table in question. */ getColumnsFromTable(table: TableModelInterface): ColumnModelInterface[]; /** * Whether the given table has all of this unique key's columns. * * @param table Table in question. */ hasAllColumnsFromTable(table: TableModelInterface): boolean; /** * Set size of this index to the size of index's column in given * table, if the size of this index is not already set. * * @param table Table to search size for. */ setIndexSizeFromTable(table: TableModelInterface): void; /** * Rename index column name. * * @param column Column being renamed. * @param newName New column name. */ renameColumn(column: ColumnModelInterface, newName: string): void; }