Skip to content

Commit 8e1f43e

Browse files
committed
Revert legacy attachment changes
1 parent 3fe3cd9 commit 8e1f43e

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

packages/attachments/src/Schema.ts

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ColumnsType, Table, column, TableOptions } from '@powersync/common';
1+
import { Column, ColumnType, ResolvedTable, ResolvedTableOptions, Table } from '@powersync/common';
22

33
export const ATTACHMENT_TABLE = 'attachments';
44

@@ -20,31 +20,27 @@ export enum AttachmentState {
2020
ARCHIVED = 4 // Attachment has been orphaned, i.e. the associated record has been deleted
2121
}
2222

23-
export interface AttachmentTableOptions extends Omit<TableOptions, 'name' | 'columns'> {
23+
export interface AttachmentTableOptions extends Omit<ResolvedTableOptions, 'name' | 'columns'> {
2424
name?: string;
25-
additionalColumns?: ColumnsType;
25+
additionalColumns?: Column[];
2626
}
2727

28-
export class AttachmentTable extends Table {
28+
export class AttachmentTable extends ResolvedTable {
2929
constructor(options?: AttachmentTableOptions) {
30-
const { additionalColumns = {}, ...tableOptions } = options ?? {};
31-
32-
super(
33-
{
34-
filename: column.text,
35-
local_uri: column.text,
36-
timestamp: column.integer,
37-
size: column.integer,
38-
media_type: column.text,
39-
state: column.integer,
40-
...additionalColumns
41-
},
42-
{
43-
name: ATTACHMENT_TABLE,
44-
...tableOptions,
45-
localOnly: true,
46-
insertOnly: false
47-
}
48-
);
30+
super({
31+
...options,
32+
name: options?.name ?? ATTACHMENT_TABLE,
33+
localOnly: true,
34+
insertOnly: false,
35+
columns: [
36+
new Column({ name: 'filename', type: ColumnType.TEXT }),
37+
new Column({ name: 'local_uri', type: ColumnType.TEXT }),
38+
new Column({ name: 'timestamp', type: ColumnType.INTEGER }),
39+
new Column({ name: 'size', type: ColumnType.INTEGER }),
40+
new Column({ name: 'media_type', type: ColumnType.TEXT }),
41+
new Column({ name: 'state', type: ColumnType.INTEGER }), // Corresponds to AttachmentState
42+
...(options?.additionalColumns ?? [])
43+
]
44+
});
4945
}
5046
}

0 commit comments

Comments
 (0)