Skip to content

Commit

Permalink
migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomorebonato committed Nov 1, 2024
1 parent f83f6bc commit d4604f7
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ node_modules/
tmp/
pb_data/
.env
./pocket-react
pocket-react
dist/
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ COPY --from=builder-golang /app/pocket-react /pb/pocket-react
# COPY ./pb_hooks /pb/pb_hooks

EXPOSE 8090
RUN /pb/pocket-react migrate history-sync
RUN /pb/pocket-react migrate up

CMD ["/pb/pocket-react", "serve", "--http=0.0.0.0:8090"]
10 changes: 0 additions & 10 deletions frontend/pocketbase-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type PocketBase from 'pocketbase'
import type { RecordService } from 'pocketbase'

export enum Collections {
Notes = "notes",
Users = "users",
}

Expand Down Expand Up @@ -34,36 +33,27 @@ export type AuthSystemFields<T = never> = {

// Record types for each collection

export type NotesRecord = {
content?: string
title?: string
}

export type UsersRecord = {
avatar?: string
name?: string
}

// Response types include system fields and match responses from the PocketBase API
export type NotesResponse<Texpand = unknown> = Required<NotesRecord> & BaseSystemFields<Texpand>
export type UsersResponse<Texpand = unknown> = Required<UsersRecord> & AuthSystemFields<Texpand>

// Types containing all Records and Responses, useful for creating typing helper functions

export type CollectionRecords = {
notes: NotesRecord
users: UsersRecord
}

export type CollectionResponses = {
notes: NotesResponse
users: UsersResponse
}

// Type for usage with type asserted PocketBase instance
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions

export type TypedPocketBase = PocketBase & {
collection(idOrName: 'notes'): RecordService<NotesResponse>
collection(idOrName: 'users'): RecordService<UsersResponse>
}
2 changes: 1 addition & 1 deletion frontend/routes/notes/$noteId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Route = createFileRoute('/notes/$noteId')({
<div className='w-full grid grid-cols-5'>
<div className='col-span-1 flex flex-col gap-2 p-2'>
<button
className='btn btn-primary pb-2'
className='btn btn-primary'
type='button'
onClick={() => {
if (dialogRef.current) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"build:client": "tsc -b && vite build",
"build:server": "go build -tags production -o pocket-react",
"format": "pnpm biome check --write ./frontend/",
"migrate": "pocketbase migrate collections"
"migrate": "pocketbase migrate collections",
"migrate:sync": "go run ./main.go ./embed_dev.go migrate history-sync"
},
"dependencies": {
"@heroicons/react": "^2.1.5",
Expand Down
Binary file modified pocket-react
Binary file not shown.

0 comments on commit d4604f7

Please sign in to comment.