Skip to content

Commit 9a574b1

Browse files
gqcnclaude
andcommitted
feat(dialect): add SQLite database dialect abstraction and support
Introduce pkg/dialect/ with MySQL/SQLite implementations, DDL translation for SQLite, generalized database init/mock commands, rename kvcache mysql-memory to sqltable, add SQLite CI smoke tests and E2E coverage, improve frontend discard-changes UX and toolbar testability, and update sqlite-database-support OpenSpec artifacts. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent eeaee65 commit 9a574b1

99 files changed

Lines changed: 5487 additions & 2642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main-ci.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ env:
3434
TZ: "Asia/Shanghai"
3535

3636
jobs:
37-
unit-tests:
37+
# Backend Unit Tests
38+
backend-unit-tests:
3839
runs-on: ubuntu-latest
3940

4041
services:
@@ -85,3 +86,26 @@ jobs:
8586
- name: Run Unit Tests
8687
run: |
8788
cd apps/lina-core && go test -v ./...
89+
90+
# SQLite Backend Smoke Tests
91+
sqlite-smoke:
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- name: Setup Timezone
96+
uses: szenius/set-timezone@v2.0
97+
with:
98+
timezoneLinux: "Asia/Shanghai"
99+
100+
- name: Checkout Repository
101+
uses: actions/checkout@v5
102+
103+
- name: Setup Go
104+
uses: actions/setup-go@v5
105+
with:
106+
go-version: "1.25"
107+
cache-dependency-path: '**/go.sum'
108+
109+
- name: Run SQLite Backend Smoke
110+
run: |
111+
./hack/tests/scripts/run-sqlite-smoke.sh

LICENSE

Lines changed: 126 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
not limited to compiled object code, generated documentation,
3333
and conversions to other media types.
3434

35-
"Work" shall mean the work of authorship made available under
36-
the License, as indicated by a copyright notice that is included in
37-
or attached to the work (an example is provided in the Appendix below).
35+
"Work" shall mean the work of authorship, whether in Source or
36+
Object form, made available under the License, as indicated by a
37+
copyright notice that is included in or attached to the work
38+
(an example is provided in the Appendix below).
3839

3940
"Derivative Works" shall mean any work, whether in Source or Object
4041
form, that is based on (or derived from) the Work and for which the
@@ -44,21 +45,23 @@
4445
separable from, or merely link (or bind by name) to the interfaces of,
4546
the Work and Derivative Works thereof.
4647

47-
"Contribution" shall mean, as submitted to the Licensor for inclusion
48-
in the Work by the copyright owner or by an individual or Legal Entity
49-
authorized to submit on behalf of the copyright owner. For the purposes
50-
of this definition, "submitted" means any form of electronic, verbal,
51-
or written communication sent to the Licensor or its representatives,
52-
including but not limited to communication on electronic mailing lists,
53-
source code control systems, and issue tracking systems that are managed
54-
by, or on behalf of, the Licensor for the purpose of discussing and
55-
improving the Work, but excluding communication that is conspicuously
56-
marked or otherwise designated in writing by the copyright owner as
57-
"Not a Contribution."
58-
59-
"Contributor" shall mean Licensor and any Legal Entity on behalf of
60-
whom a Contribution has been received by the Licensor and subsequently
61-
incorporated within the Work.
48+
"Contribution" shall mean any work of authorship, including
49+
the original version of the Work and any modifications or additions
50+
to that Work or Derivative Works thereof, that is intentionally
51+
submitted to Licensor for inclusion in the Work by the copyright owner
52+
or by an individual or Legal Entity authorized to submit on behalf of
53+
the copyright owner. For the purposes of this definition, "submitted"
54+
means any form of electronic, verbal, or written communication sent
55+
to the Licensor or its representatives, including but not limited to
56+
communication on electronic mailing lists, source code control systems,
57+
and issue tracking systems that are managed by, or on behalf of, the
58+
Licensor for the purpose of discussing and improving the Work, but
59+
excluding communication that is conspicuously marked or otherwise
60+
designated in writing by the copyright owner as "Not a Contribution."
61+
62+
"Contributor" shall mean Licensor and any individual or Legal Entity
63+
on behalf of whom a Contribution has been received by Licensor and
64+
subsequently incorporated within the Work.
6265

6366
2. Grant of Copyright License. Subject to the terms and conditions of
6467
this License, each Contributor hereby grants to You a perpetual,
@@ -76,92 +79,121 @@
7679
by such Contributor that are necessarily infringed by their
7780
Contribution(s) alone or by combination of their Contribution(s)
7881
with the Work to which such Contribution(s) was submitted. If You
79-
institute patent litigation against any entity (including a cross-claim
80-
or counterclaim in a lawsuit) alleging that the Work or a Contribution
81-
incorporated within the Work constitutes direct or contributory patent
82-
infringement, then any patent licenses granted to You under this License
83-
for that Work shall terminate as of the date such litigation is filed.
84-
85-
4. Redistribution. You may reproduce and distribute copies of the Work
86-
or Derivative Works thereof in any medium, with or without
87-
modifications, and in Source or Object form, provided that You meet
88-
the following conditions:
89-
90-
(a) You must give any other recipients of the Work or Derivative Works
91-
a copy of this License; and
92-
93-
(b) You must cause any modified files to carry prominent notices stating
94-
that You changed the files; and
95-
96-
(c) You must retain, in the Source form of any Derivative Works that
97-
You distribute, all copyright, patent, trademark, and attribution
98-
notices from the Source form of the Work, excluding those notices
99-
that do not pertain to any part of the Derivative Works; and
82+
institute patent litigation against any entity (including a
83+
cross-claim or counterclaim in a lawsuit) alleging that the Work
84+
or a Contribution incorporated within the Work constitutes direct
85+
or contributory patent infringement, then any patent licenses
86+
granted to You under this License for that Work shall terminate
87+
as of the date such litigation is filed.
88+
89+
4. Redistribution. You may reproduce and distribute copies of the
90+
Work or Derivative Works thereof in any medium, with or without
91+
modifications, and in Source or Object form, provided that You
92+
meet the following conditions:
93+
94+
(a) You must give any other recipients of the Work or
95+
Derivative Works a copy of this License; and
96+
97+
(b) You must cause any modified files to carry prominent notices
98+
stating that You changed the files; and
99+
100+
(c) You must retain, in the Source form of any Derivative Works
101+
that You distribute, all copyright, patent, trademark, and
102+
attribution notices from the Source form of the Work,
103+
excluding those notices that do not pertain to any part of
104+
the Derivative Works; and
100105

101106
(d) If the Work includes a "NOTICE" text file as part of its
102-
distribution, You must include a readable copy of the attribution
103-
notices contained within such NOTICE file, in at least one of
104-
the following places: within a NOTICE text file distributed as
105-
part of the Derivative Works; within the Source form or documentation,
106-
if provided along with the Derivative Works; or, within a display
107-
generated by the Derivative Works, if and wherever such third-party
108-
notices normally appear. The contents of the NOTICE file are for
109-
informational purposes only and do not modify the License. You may
110-
add Your own attribution notices within Derivative Works that You
111-
distribute, alongside or as an addendum to the NOTICE text from
112-
the Work, provided that such additional attribution notices cannot
113-
be construed as modifying the License.
114-
115-
You may add Your own license statement for Your modifications and may
116-
provide additional or different license terms and conditions for use,
117-
reproduction, or distribution of Your modifications, or for such
118-
Derivative Works as a whole, provided Your use, reproduction, and
119-
distribution of the Work otherwise complies with the conditions stated
120-
in this License.
107+
distribution, then any Derivative Works that You distribute must
108+
include a readable copy of the attribution notices contained
109+
within such NOTICE file, excluding those notices that do not
110+
pertain to any part of the Derivative Works, in at least one
111+
of the following places: within a NOTICE text file distributed
112+
as part of the Derivative Works; within the Source form or
113+
documentation, if provided along with the Derivative Works; or,
114+
within a display generated by the Derivative Works, if and
115+
wherever such third-party notices normally appear. The contents
116+
of the NOTICE file are for informational purposes only and
117+
do not modify the License. You may add Your own attribution
118+
notices within Derivative Works that You distribute, alongside
119+
or as an addendum to the NOTICE text from the Work, provided
120+
that such additional attribution notices cannot be construed
121+
as modifying the License.
122+
123+
You may add Your own copyright statement to Your modifications and
124+
may provide additional or different license terms and conditions
125+
for use, reproduction, or distribution of Your modifications, or
126+
for any such Derivative Works as a whole, provided Your use,
127+
reproduction, and distribution of the Work otherwise complies with
128+
the conditions stated in this License.
121129

122130
5. Submission of Contributions. Unless You explicitly state otherwise,
123-
any Contribution intentionally submitted for inclusion in the Work by
124-
You to the Licensor shall be under the terms and conditions of this
125-
License, without any additional terms or conditions. Notwithstanding
126-
the above, nothing herein shall supersede or modify the terms of any
127-
separate license agreement you may have executed with Licensor regarding
128-
such Contributions.
131+
any Contribution intentionally submitted for inclusion in the Work
132+
by You to the Licensor shall be under the terms and conditions of
133+
this License, without any additional terms or conditions.
134+
Notwithstanding the above, nothing herein shall supersede or modify
135+
the terms of any separate license agreement you may have executed
136+
with Licensor regarding such Contributions.
129137

130138
6. Trademarks. This License does not grant permission to use the trade
131139
names, trademarks, service marks, or product names of the Licensor,
132140
except as required for reasonable and customary use in describing the
133141
origin of the Work and reproducing the content of the NOTICE file.
134142

135143
7. Disclaimer of Warranty. Unless required by applicable law or
136-
agreed to in writing, Licensor provides the Work (and each Contributor
137-
provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
138-
OR CONDITIONS OF ANY KIND, either express or implied, including,
139-
without limitation, any warranties or conditions of TITLE,
140-
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
141-
You are solely responsible for determining the appropriateness of using
142-
or redistributing the Work and assume any risks associated with Your
143-
exercise of permissions under this License.
144+
agreed to in writing, Licensor provides the Work (and each
145+
Contributor provides its Contributions) on an "AS IS" BASIS,
146+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147+
implied, including, without limitation, any warranties or conditions
148+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149+
PARTICULAR PURPOSE. You are solely responsible for determining the
150+
appropriateness of using or redistributing the Work and assume any
151+
risks associated with Your exercise of permissions under this License.
144152

145153
8. Limitation of Liability. In no event and under no legal theory,
146-
whether in tort (including negligence), contract, or otherwise, unless
147-
required by applicable law (such as deliberate and grossly negligent
148-
acts) or agreed to in writing, shall any Contributor be liable to You
149-
for damages, including any direct, indirect, special, incidental, or
150-
consequential damages of any character arising as a result of this
151-
License or out of the use or inability to use the Work (including but
152-
not limited to damages for loss of goodwill, work stoppage, computer
153-
failure or malfunction, or all other commercial damages or losses), even
154-
if such Contributor has been advised of the possibility of such damages.
155-
156-
9. Accepting Warranty or Additional Liability. While redistributing the
157-
Work or Derivative Works thereof, You may choose to offer, and charge
158-
a fee for, acceptance of support, warranty, indemnity, or other
159-
liability obligations and/or rights consistent with this License.
160-
However, in accepting such obligations, You may charge only on Your
161-
own behalf and on Your sole responsibility, not on behalf of any other
162-
Contributor, and only if You agree to indemnify, defend, and hold each
163-
Contributor harmless for any liability incurred by, or claims asserted
164-
against, such Contributor by reason of your accepting any such warranty
165-
or additional liability.
166-
167-
END OF TERMS AND CONDITIONS
154+
whether in tort (including negligence), contract, or otherwise,
155+
unless required by applicable law (such as deliberate and grossly
156+
negligent acts) or agreed to in writing, shall any Contributor be
157+
liable to You for damages, including any direct, indirect, special,
158+
incidental, or consequential damages of any character arising as a
159+
result of this License or out of the use or inability to use the
160+
Work (including but not limited to damages for loss of goodwill,
161+
work stoppage, computer failure or malfunction, or any and all
162+
other commercial damages or losses), even if such Contributor
163+
has been advised of the possibility of such damages.
164+
165+
9. Accepting Warranty or Additional Liability. While redistributing
166+
the Work or Derivative Works thereof, You may choose to offer,
167+
and charge a fee for, acceptance of support, warranty, indemnity,
168+
or other liability obligations and/or rights consistent with this
169+
License. However, in accepting such obligations, You may act only
170+
on Your own behalf and on Your sole responsibility, not on behalf
171+
of any other Contributor, and only if You agree to indemnify,
172+
defend, and hold each Contributor harmless for any liability
173+
incurred by, or claims asserted against, such Contributor by reason
174+
of your accepting any such warranty or additional liability.
175+
176+
END OF TERMS AND CONDITIONS
177+
178+
APPENDIX: How to apply the Apache License to your work.
179+
180+
To apply the Apache License to your work, attach the following
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182+
replaced with your own identifying information. (Don't include
183+
the brackets!) The text should be enclosed in the appropriate
184+
comment syntax for the file format. We also recommend that a
185+
file or class name and description of purpose be included on the
186+
same "printed page" as the copyright notice for easier
187+
identification within third-party archives.
188+
189+
Licensed under the Apache License, Version 2.0 (the "License");
190+
you may not use this file except in compliance with the License.
191+
You may obtain a copy of the License at
192+
193+
http://www.apache.org/licenses/LICENSE-2.0
194+
195+
Unless required by applicable law or agreed to in writing, software
196+
distributed under the License is distributed on an "AS IS" BASIS,
197+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
198+
See the License for the specific language governing permissions and
199+
limitations under the License.

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ include hack/makefiles/test.mk
2323
include hack/makefiles/i18n.mk
2424

2525
# Initialize the backend database with schema and required seed data.
26+
# The backend dispatches by database.default.link, for example MySQL or SQLite.
2627
# 初始化后端数据库表结构和系统必需的种子数据。
28+
# 后端会按 database.default.link 自动分发到 MySQL 或 SQLite 等方言。
2729
## init: Initialize the database with DDL and seed data only
2830
.PHONY: init
2931
init:
@@ -36,7 +38,9 @@ init:
3638
@cd $(BACKEND_DIR) && $(MAKE) init confirm=$(confirm) $(if $(rebuild),rebuild=$(rebuild),)
3739

3840
# Load optional mock data for local demos and development verification.
41+
# Mock loading uses the same database.default.link dialect and requires init first.
3942
# 加载用于本地演示和开发验证的可选 Mock 数据。
43+
# Mock 加载使用同一个 database.default.link 方言,并要求先完成 init。
4044
## mock: Load mock demo data after init
4145
.PHONY: mock
4246
mock:

0 commit comments

Comments
 (0)