Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
c29c1d3e
Commit
c29c1d3e
authored
Jan 07, 2026
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: seed data
parent
cc9a214b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
15 deletions
+8
-15
AGENTS.md
AGENTS.md
+1
-8
migrator.go
store/migrator.go
+6
-6
01__dump.sql
store/seed/sqlite/01__dump.sql
+1
-1
No files found.
AGENTS.md
View file @
c29c1d3e
...
@@ -165,7 +165,7 @@ type Driver interface {
...
@@ -165,7 +165,7 @@ type Driver interface {
4.
Demo mode: Seed with demo data
4.
Demo mode: Seed with demo data
**Schema Versioning:**
**Schema Versioning:**
-
Stored in
`
instance_setting`
table (key:
`bb.general.version`
)
-
Stored in
`
system_setting`
table
-
Format:
`major.minor.patch`
-
Format:
`major.minor.patch`
-
Migration files:
`store/migration/{driver}/{version}/NN__description.sql`
-
Migration files:
`store/migration/{driver}/{version}/NN__description.sql`
-
See:
`store/migrator.go:21-414`
-
See:
`store/migrator.go:21-414`
...
@@ -503,13 +503,6 @@ cd web && pnpm lint
...
@@ -503,13 +503,6 @@ cd web && pnpm lint
## Common Tasks
## Common Tasks
### Debugging Database Issues
1. Check connection string in logs
2. Verify `store/db/{driver}/migration/` files exist
3. Check schema version: `SELECT * FROM instance_setting WHERE key = 'bb.general.version'`
4. Test migration: `go test ./store/test/... -v`
### Debugging API Issues
### Debugging API Issues
1. Check Connect interceptor logs: `server/router/api/v1/connect_interceptors.go:79-105`
1. Check Connect interceptor logs: `server/router/api/v1/connect_interceptors.go:79-105`
...
...
store/migrator.go
View file @
c29c1d3e
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
// Migration System Overview:
// Migration System Overview:
//
//
// The migration system handles database schema versioning and upgrades.
// The migration system handles database schema versioning and upgrades.
// Schema version is stored in
instance_setting (formerly system_setting)
.
// Schema version is stored in
system_setting
.
//
//
// Migration Flow:
// Migration Flow:
// 1. preMigrate: Check if DB is initialized. If not, apply LATEST.sql
// 1. preMigrate: Check if DB is initialized. If not, apply LATEST.sql
...
@@ -30,9 +30,9 @@ import (
...
@@ -30,9 +30,9 @@ import (
// 4. Migrate (demo mode): Seed database with demo data
// 4. Migrate (demo mode): Seed database with demo data
//
//
// Version Tracking:
// Version Tracking:
// - New installations: Schema version set in
instance
_setting immediately
// - New installations: Schema version set in
system
_setting immediately
// - Existing v0.22+ installations: Schema version tracked in
instance
_setting
// - Existing v0.22+ installations: Schema version tracked in
system
_setting
// - Pre-v0.22 installations: Must upgrade to v0.25.x first (migration_history →
instance
_setting migration)
// - Pre-v0.22 installations: Must upgrade to v0.25.x first (migration_history →
system
_setting migration)
//
//
// Migration Files:
// Migration Files:
// - Location: store/migration/{driver}/{version}/NN__description.sql
// - Location: store/migration/{driver}/{version}/NN__description.sql
...
@@ -373,7 +373,7 @@ func (s *Store) updateCurrentSchemaVersion(ctx context.Context, schemaVersion st
...
@@ -373,7 +373,7 @@ func (s *Store) updateCurrentSchemaVersion(ctx context.Context, schemaVersion st
// checkMinimumUpgradeVersion verifies the installation meets minimum version requirements for upgrade.
// checkMinimumUpgradeVersion verifies the installation meets minimum version requirements for upgrade.
// For very old installations (< v0.22.0), users must upgrade to v0.25.x first before upgrading to current version.
// For very old installations (< v0.22.0), users must upgrade to v0.25.x first before upgrading to current version.
// This is necessary because schema version tracking was moved from migration_history to
instance
_setting in v0.22.0.
// This is necessary because schema version tracking was moved from migration_history to
system
_setting in v0.22.0.
func
(
s
*
Store
)
checkMinimumUpgradeVersion
(
ctx
context
.
Context
)
error
{
func
(
s
*
Store
)
checkMinimumUpgradeVersion
(
ctx
context
.
Context
)
error
{
instanceBasicSetting
,
err
:=
s
.
GetInstanceBasicSetting
(
ctx
)
instanceBasicSetting
,
err
:=
s
.
GetInstanceBasicSetting
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -401,7 +401,7 @@ func (s *Store) checkMinimumUpgradeVersion(ctx context.Context) error {
...
@@ -401,7 +401,7 @@ func (s *Store) checkMinimumUpgradeVersion(ctx context.Context) error {
"2. Start the server and verify it works
\n
"
+
"2. Start the server and verify it works
\n
"
+
"3. Then upgrade to the latest version
\n\n
"
+
"3. Then upgrade to the latest version
\n\n
"
+
"This is required because schema version tracking was moved from migration_history
\n
"
+
"This is required because schema version tracking was moved from migration_history
\n
"
+
"to
instance
_setting in v0.22.0. The intermediate upgrade handles this migration safely."
,
"to
system
_setting in v0.22.0. The intermediate upgrade handles this migration safely."
,
schemaVersion
,
schemaVersion
,
currentVersion
,
currentVersion
,
)
)
...
...
store/seed/sqlite/01__dump.sql
View file @
c29c1d3e
...
@@ -36,4 +36,4 @@ INSERT INTO reaction (id,creator_id,content_id,reaction_type) VALUES(4,1,'memos/
...
@@ -36,4 +36,4 @@ INSERT INTO reaction (id,creator_id,content_id,reaction_type) VALUES(4,1,'memos/
INSERT
INTO
reaction
(
id
,
creator_id
,
content_id
,
reaction_type
)
VALUES
(
5
,
1
,
'memos/sponsor0000001'
,
'👍'
);
INSERT
INTO
reaction
(
id
,
creator_id
,
content_id
,
reaction_type
)
VALUES
(
5
,
1
,
'memos/sponsor0000001'
,
'👍'
);
-- System Settings
-- System Settings
INSERT
INTO
instance
_setting
VALUES
(
'MEMO_RELATED'
,
'{"contentLengthLimit":8192,"enableAutoCompact":true,"enableComment":true,"enableLocation":true,"defaultVisibility":"PUBLIC","reactions":["👍","💛","🔥","👏","😂","👌","🚀","👀","🤔","🤡","❓","+1","🎉","💡","✅"]}'
,
''
);
INSERT
INTO
system
_setting
VALUES
(
'MEMO_RELATED'
,
'{"contentLengthLimit":8192,"enableAutoCompact":true,"enableComment":true,"enableLocation":true,"defaultVisibility":"PUBLIC","reactions":["👍","💛","🔥","👏","😂","👌","🚀","👀","🤔","🤡","❓","+1","🎉","💡","✅"]}'
,
''
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment