update pocketbase,

This commit is contained in:
louiscklaw
2025-04-18 03:06:06 +08:00
parent d863d6d469
commit 03313dfc65
993 changed files with 71724 additions and 19 deletions

View File

@@ -0,0 +1,3 @@
{
"printWidth": 180
}

View File

@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

View File

@@ -0,0 +1,15 @@
# README
## to seed a pocketbase
```bash
# this will create a new database and re-initialize tables
$ docker compose up -d
# re-inject data content
$ docker compose exec -it pocketbase sh
$ pocketbase seed_db
# inside docker prompt, press seed_w
/# nodemon -w /pb_hooks --exec "pocketbase seed"
```

View File

@@ -0,0 +1,30 @@
FROM alpine:3 as downloader
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG VERSION
ENV BUILDX_ARCH="${TARGETOS:-linux}_${TARGETARCH:-amd64}${TARGETVARIANT}"
RUN wget https://github.com/pocketbase/pocketbase/releases/download/v${VERSION}/pocketbase_${VERSION}_${BUILDX_ARCH}.zip \
&& unzip pocketbase_${VERSION}_${BUILDX_ARCH}.zip \
&& chmod +x /pocketbase
FROM alpine:3
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
EXPOSE 8090
COPY --from=downloader /pocketbase /usr/local/bin/pocketbase
# ---
RUN apk add sqlite entr
COPY entrypoint.sh /entrypoint.sh
# ENTRYPOINT ["/entrypoint.sh"]
RUN apk add nodejs yarn
RUN yarn global add nodemon
ENTRYPOINT ["/usr/local/bin/pocketbase", "serve", "--http=0.0.0.0:8090", "--dir=/pb_data", "--publicDir=/pb_public", "--hooksDir=/pb_hooks"]

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env sh
set -ex
sleep 1
# original from dockerfile
echo "init first migration for create user"
/usr/local/bin/pocketbase migrate up
echo "create admin account"
# /usr/local/bin/pocketbase superuser upsert admin@123.com Aa12345678
/usr/local/bin/pocketbase migrate up --dir=/pb_data --migrationsDir=/pb_migrations
echo "start server"
/usr/local/bin/pocketbase serve \
--http=0.0.0.0:8090 \
--dir=/pb_data \
--migrationsDir=/pb_migrations \
--publicDir=/pb_public \
--hooksDir=/pb_hooks &
sleep 5
echo "calling hook"
/usr/local/bin/pocketbase hello

23315
002_source/pocketbase/pb_data/types.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +1,36 @@
module.exports = $app => {
module.exports = ($app) => {
let draft_lesson_types = [
['1'.padStart(15, 0), 'Vocabulary', 'vocabulary', 0, 'visible'],
['2'.padStart(15, 0), 'Connectives', 'connectivse', 1, 'visible'],
['3'.padStart(15, 0), 'Testing visible', 'testing', 3, 'visible'],
['4'.padStart(15, 0), 'Testing hidden', 'testing', 3, 'hidden'],
['5'.padStart(15, 0), 'lesson type 5', 'testing', 3, 'hidden'],
['6'.padStart(15, 0), '中文 6', 'testing', 3, 'hidden'],
['7'.padStart(15, 0), 'レッスン7 レッスン7 レッスン7', 'testing', 3, 'hidden'],
["1".padStart(15, 0), "Vocabulary", "vocabulary", 0, "visible"],
["2".padStart(15, 0), "Connectives", "connectives", 1, "visible"],
["3".padStart(15, 0), "Testing visible", "testing", 3, "visible"],
["4".padStart(15, 0), "Testing hidden", "testing", 3, "hidden"],
["5".padStart(15, 0), "lesson type 5", "testing", 3, "hidden"],
["6".padStart(15, 0), "中文 6", "testing", 3, "hidden"],
["7".padStart(15, 0), "レッスン7 レッスン7 レッスン7", "testing", 3, "hidden"],
];
dirtyTruncateTable('LessonsTypes');
dirtyTruncateTable("LessonsTypes");
let lt_collection = $app.findCollectionByNameOrId('LessonsTypes');
let lt_collection = $app.findCollectionByNameOrId("LessonsTypes");
for (let i = 0; i < draft_lesson_types.length; i++) {
let lesson_type = draft_lesson_types[i];
let record = new Record(lt_collection);
record.set('id', lesson_type[0]);
record.set('name', lesson_type[1]);
record.set('type', lesson_type[2]);
record.set('pos', lesson_type[3]);
record.set('visible', lesson_type[4]);
record.set("id", lesson_type[0]);
record.set("name", lesson_type[1]);
record.set("type", lesson_type[2]);
record.set("pos", lesson_type[3]);
record.set("visible", lesson_type[4]);
// record.set("created", new Date(Date.now() - i * 1000 * 60 * 60));
// record.set("updated", new Date(Date.now() - i * 1000 * 60 * 60));
$app.save(record);
}
console.log('seeding done');
console.log("seeding done");
};
const dirtyTruncateTable = COLLECTION_NAME => {
const dirtyTruncateTable = (COLLECTION_NAME) => {
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
const cmd_to_exec = $os.cmd('sqlite3', '/pb_data/data.db', `DELETE from ${COLLECTION_NAME};`);
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
cmd_to_exec.output();
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
// pb_migrations/0000000001_create_superuser.js
migrate(
(app) => {
const superusers_collection = app.findCollectionByNameOrId("_superusers");
const record = new Record(superusers_collection);
record.set("email", "admin@123.com");
record.set("password", "Aa12345678");
app.save(record);
console.log("Superuser admin@123.com created via migration");
},
(app) => {
try {
const record = app.findAuthRecordByEmail(
"_superusers",
"admin@example.com"
);
app.delete(record);
} catch {
// silent errors (probably already deleted)
}
}
);

View File

@@ -0,0 +1,88 @@
/// <reference path="../pb_data/types.d.ts" />
migrate(
(app) => {
const collection = new Collection({
createRule: null,
deleteRule: null,
fields: [
{
autogeneratePattern: "[a-z0-9]{15}",
hidden: false,
id: "text3208210256",
max: 15,
min: 15,
name: "id",
pattern: "^[a-z0-9]+$",
presentable: false,
primaryKey: true,
required: true,
system: true,
type: "text",
},
{
autogeneratePattern: "",
hidden: false,
id: "text907060870",
max: 0,
min: 0,
name: "hello",
pattern: "",
presentable: false,
primaryKey: false,
required: false,
system: false,
type: "text",
},
{
hidden: false,
id: "file2313559263",
maxSelect: 1,
maxSize: 0,
mimeTypes: [],
name: "test_file",
presentable: false,
protected: false,
required: false,
system: false,
thumbs: [],
type: "file",
},
{
hidden: false,
id: "autodate2990389176",
name: "created",
onCreate: true,
onUpdate: false,
presentable: false,
system: false,
type: "autodate",
},
{
hidden: false,
id: "autodate3332085495",
name: "updated",
onCreate: true,
onUpdate: true,
presentable: false,
system: false,
type: "autodate",
},
],
id: "pbc_2109205374",
indexes: [],
listRule: null,
name: "t3",
system: false,
type: "base",
updateRule: null,
viewRule: null,
});
return app.save(collection);
},
(app) => {
const collection = app.findCollectionByNameOrId("pbc_2109205374");
return app.delete(collection);
}
);

View File

@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_2109205374")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_2109205374")
// update collection data
unmarshal({
"createRule": null,
"deleteRule": null,
"listRule": null,
"updateRule": null,
"viewRule": null
}, collection)
return app.save(collection)
})

View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# read -p "Press Enter to start..."
set -x
docker compose kill
docker compose down
sudo rm -rf ./volumes/pocketbase/pb_data/*
set -ex
sudo chown 1000:1000 -R ./volumes
sudo rm -rf ./volumes/*
docker compose build
docker compose up -d
# docker compose logs -f
echo "please run yourself !!!!"
echo "yarn nodemon -w /pb_hooks --exec "pocketbase seed""
echo ""
docker compose exec -it pocketbase sh

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":null,"md5":"9HCecuVeThI3AHm+vrVOEA=="}

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":null,"md5":"9HCecuVeThI3AHm+vrVOEA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":null,"md5":"m6+cQ76fESQ8L5LuoAMoLQ=="}

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":null,"md5":"m6+cQ76fESQ8L5LuoAMoLQ=="}

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":null,"md5":"m6+cQ76fESQ8L5LuoAMoLQ=="}

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":null,"md5":"m6+cQ76fESQ8L5LuoAMoLQ=="}

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":null,"md5":"m6+cQ76fESQ8L5LuoAMoLQ=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_technology.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_technology.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_technology.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_technology.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

View File

@@ -0,0 +1 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_technology.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

Some files were not shown because too many files have changed in this diff Show More