Skip to content

Commit

Permalink
feat: pgroll cli edit (#1430)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Rico <[email protected]>
Co-authored-by: Alexis Rico <[email protected]>
Co-authored-by: Andrew Farries <[email protected]>
  • Loading branch information
3 people committed Jul 4, 2024
1 parent 56c09d1 commit a4eb87b
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions cli/src/commands/schema/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { Schemas } from '@xata.io/client';

export type BranchSchemaFormatted =
| {
schema: {
tables: {
name: string;
uniqueConstraints: Schemas.BranchSchema['tables'][number]['uniqueConstraints'];
checkConstraints: Schemas.BranchSchema['tables'][number]['checkConstraints'];
foreignKeys: Schemas.BranchSchema['tables'][number]['foreignKeys'];
columns: {
name: string;
type: string;
unique: boolean;
notNull: boolean;
defaultValue: any;
comment: string;
}[];
}[];
};
}
| undefined;

export type ColumnData = {
name: string;
type: string;
unique: boolean;
nullable: boolean;
defaultValue?: string;
vector?: {
dimension: number;
};
originalName: string;
tableName: string;
link?: {
table: string;
};
file?: {
defaultPublicAccess: boolean;
};
'file[]'?: {
defaultPublicAccess: boolean;
};
};

export type AddTablePayload = {
type: 'add-table';
table: {
name: string;
};
};

export type EditTablePayload = {
type: 'edit-table';
table: {
name: string;
newName: string;
};
};

export type DeleteTablePayload = {
name: string;
};

export type AddColumnPayload = {
type: 'add-column';
tableName: string;
column: ColumnData;
};

export type EditColumnPayload = {
type: 'edit-column';
column: ColumnData;
};

export type DeleteColumnPayload = { [tableName: string]: string[] };

export type FormatPayload = {
type: 'space' | 'migrate' | 'schema';
};

export type SelectChoice = {
name: FormatPayload | AddTablePayload | EditTablePayload | AddColumnPayload | EditColumnPayload;
message: string;
role?: string;
choices?: SelectChoice[];
disabled?: boolean;
hint?: string;
};

export type ValidationState = {
values: { name: string };
items: { name: string; input: string }[];
fields: { name: string; initial: string }[];
};

export type ColumnAdditions = { [tableName: string]: { [columnName: string]: AddColumnPayload['column'] } };

export type ColumnEdits = { [tableName: string]: { [columnName: string]: AddColumnPayload['column'] } };

0 comments on commit a4eb87b

Please sign in to comment.