Query schema history.

https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/schema/history

Query the branch its schema history.

Expected parameters

NameDescriptionInRequiredSchema
db_branch_name

The DBBranchName matches the pattern {db_name}:{branch_name}.

path✅string

Query Schema History.

POST
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/schema/history

Request Body Type Definition

type GetBranchSchemaHistory = {
    page?: {
        /**
         * Query the next page that follow the cursor.
         */
        after?: string;
        /**
         * Query the previous page before the cursor.
         */
        before?: string;
        /**
         * Set page size. If the size is missing it is read from the cursor. If no cursor is given xata will choose the default page size.
         *
         * @default 20
         */
        size?: number;
    };
    /**
     * Report only migrations that have been added since the given Migration ID.
     */
    since?: string;
};

Responses

type GetBranchSchemaHistory = {
    meta: {
        /**
         * last record id
         */
        cursor: string;
        /**
         * true if more records can be fetch
         */
        more: boolean;
    };
    logs: Commit[];
};
 
type Commit = {
    title?: string;
    message?: string;
    id: string;
    parentID?: string;
    checksum: string;
    mergeParentID?: string;
    createdAt: DateTime;
    operations: MigrationOp[];
};
 
/**
 * @format date-time
 */
type DateTime = string;
 
/**
 * Branch schema migration operations.
 */
type MigrationOp = MigrationTableOp | MigrationColumnOp;
 
type MigrationTableOp = {
    addTable: TableOpAdd;
} | {
    removeTable: TableOpRemove;
} | {
    renameTable: TableOpRename;
};
 
type MigrationColumnOp = {
    addColumn: ColumnOpAdd;
} | {
    removeColumn: ColumnOpRemove;
} | {
    renameColumn: ColumnOpRename;
};
 
type TableOpAdd = {
    table: string;
};
 
type TableOpRemove = {
    table: string;
};
 
type TableOpRename = {
    oldName: string;
    newName: string;
};
 
type ColumnOpAdd = {
    table: string;
    column: Column;
};
 
type ColumnOpRemove = {
    table: string;
    column: string;
};
 
type ColumnOpRename = {
    table: string;
    oldName: string;
    newName: string;
};
 
type Column = {
    name: string;
    type: "bool" | "int" | "float" | "string" | "text" | "email" | "multiple" | "link" | "object" | "datetime" | "vector" | "file[]" | "file" | "json";
    link?: ColumnLink;
    vector?: ColumnVector;
    file?: ColumnFile;
    ["file[]"]?: ColumnFile;
    notNull?: boolean;
    defaultValue?: string;
    unique?: boolean;
    columns?: Column[];
};
 
type ColumnLink = {
    table: string;
};
 
type ColumnVector = {
    /**
     * @maximum 10000
     * @minimum 2
     */
    dimension: number;
};
 
type ColumnFile = {
    defaultPublicAccess?: boolean;
};