create-fullstack-scaffold 0.4.24 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +439 -15
- package/dist/cli/index.js.map +1 -1
- package/package.json +10 -13
- package/template/eslint-rules/__tests__/no-merged-api-type-export.test.ts +96 -0
- package/template/eslint-rules/no-cross-module-service-import.js +4 -0
- package/template/eslint-rules/no-merged-api-type-export.js +190 -0
- package/template/eslint.config.js +3 -0
- package/template/package.json +9 -6
- package/template/scripts/sync-agent-hooks.mjs +189 -0
- package/template/src/admin/components/__tests__/StatsCard.test.tsx +2 -2
- package/template/src/admin/pages/ContentPage.tsx +1 -1
- package/template/src/admin/pages/DisputesPage.tsx +1 -1
- package/template/src/admin/pages/OrdersPage.tsx +1 -1
- package/template/src/admin/pages/TicketsPage.tsx +1 -1
- package/template/src/admin/pages/__tests__/ContentPage.test.tsx +5 -1
- package/template/src/admin/pages/__tests__/DashboardPage.test.tsx +62 -8
- package/template/src/admin/pages/__tests__/DisputesPage.test.tsx +8 -1
- package/template/src/admin/pages/__tests__/OrdersPage.test.tsx +4 -2
- package/template/src/admin/pages/__tests__/RegisterPage.test.tsx +40 -43
- package/template/src/admin/pages/__tests__/SettingsPage.test.tsx +83 -21
- package/template/src/admin/pages/__tests__/TicketsPage.test.tsx +3 -1
- package/template/src/admin/services/apiClient.ts +2 -3
- package/template/src/cli/modules/content/index.ts +3 -3
- package/template/src/cli/modules/dispute/index.ts +3 -3
- package/template/src/cli/modules/ticket/index.ts +3 -3
- package/template/src/cli/modules/todo/index.ts +1 -1
- package/template/src/cli/rpc/client.ts +3 -4
- package/template/src/cli/rpc/index.ts +1 -1
- package/template/src/client/App.tsx +3 -39
- package/template/src/client/AppRoutes.tsx +53 -0
- package/template/src/client/entry-server.tsx +75 -0
- package/template/src/client/main.tsx +3 -1
- package/template/src/client/pages/SearchPage.tsx +1 -1
- package/template/src/client/services/apiClient.ts +12 -4
- package/template/src/client/stores/__tests__/todoStore.test.ts +12 -3
- package/template/src/client/stores/entry-stores.ts +36 -0
- package/template/src/client/stores/notificationStore.ts +4 -4
- package/template/src/client/stores/todoStore.ts +2 -2
- package/template/src/merchant/pages/DisputesPage.tsx +3 -3
- package/template/src/merchant/pages/OrdersPage.tsx +1 -1
- package/template/src/merchant/pages/ProductsPage.tsx +1 -1
- package/template/src/merchant/pages/SettingsPage.tsx +1 -1
- package/template/src/server/__tests__/integration/isr-full-flow.test.ts +251 -0
- package/template/src/server/__tests__/integration/todos-api.test.ts +7 -4
- package/template/src/server/app.ts +6 -4
- package/template/src/server/core/__tests__/isr-cache.test.ts +96 -92
- package/template/src/server/core/__tests__/isr-invalidation.test.ts +29 -4
- package/template/src/server/core/__tests__/isr-registry.test.ts +215 -0
- package/template/src/server/core/__tests__/isr-renderer.test.ts +121 -0
- package/template/src/server/core/isr-cache.ts +6 -12
- package/template/src/server/core/isr-invalidation.ts +6 -12
- package/template/src/server/core/isr-registry.ts +104 -0
- package/template/src/server/core/isr-renderer.ts +75 -0
- package/template/src/server/db/schema/contents.ts +28 -20
- package/template/src/server/db/schema/disputes.ts +30 -22
- package/template/src/server/db/schema/notifications.ts +20 -14
- package/template/src/server/db/schema/orders.ts +23 -16
- package/template/src/server/db/schema/plugins.ts +56 -38
- package/template/src/server/db/schema/products.ts +24 -17
- package/template/src/server/db/schema/tickets.ts +44 -31
- package/template/src/server/db/schema/todos.ts +26 -18
- package/template/src/server/entries/cloudflare.ts +82 -19
- package/template/src/server/entries/node.ts +0 -2
- package/template/src/server/index.ts +0 -1
- package/template/src/server/isr-modules.ts +10 -0
- package/template/src/server/module-admin/__tests__/admin-service.test.ts +36 -12
- package/template/src/server/module-admin/routes/admin-notification-routes.ts +2 -1
- package/template/src/server/module-admin/routes/admin-routes.ts +3 -0
- package/template/src/server/module-admin/routes/dashboard-routes.ts +3 -0
- package/template/src/server/module-admin/services/admin-service.ts +57 -13
- package/template/src/server/module-auth/routes/auth-routes.ts +3 -0
- package/template/src/server/module-auth/routes/profile-routes.ts +3 -0
- package/template/src/server/module-captcha/routes/captcha-routes.ts +3 -0
- package/template/src/server/module-chat/routes/chat-routes.ts +4 -1
- package/template/src/server/module-content/__tests__/content-route.test.ts +2 -1
- package/template/src/server/module-content/__tests__/content-service.test.ts +2 -1
- package/template/src/server/module-content/__tests__/isr.test.ts +138 -0
- package/template/src/server/module-content/isr.ts +63 -0
- package/template/src/server/module-content/routes/content-routes.ts +10 -10
- package/template/src/server/module-content/routes/public-content-routes.ts +8 -4
- package/template/src/server/module-content/routes/topics-routes.ts +3 -0
- package/template/src/server/module-content/services/content-service.ts +23 -10
- package/template/src/server/module-dispute/__tests__/dispute-route.test.ts +2 -1
- package/template/src/server/module-dispute/__tests__/dispute-service.test.ts +2 -1
- package/template/src/server/module-dispute/routes/dispute-routes.ts +11 -10
- package/template/src/server/module-dispute/services/dispute-service.ts +15 -3
- package/template/src/server/module-file/routes/file-routes.ts +3 -0
- package/template/src/server/module-merchant/routes/merchant-routes.ts +3 -0
- package/template/src/server/module-merchant/services/merchant-service.ts +8 -8
- package/template/src/server/module-notifications/routes/notification-routes.ts +5 -1
- package/template/src/server/module-order/__tests__/order-route.test.ts +8 -8
- package/template/src/server/module-order/__tests__/order-service.test.ts +4 -3
- package/template/src/server/module-order/routes/cart-routes.ts +3 -0
- package/template/src/server/module-order/routes/order-routes.ts +9 -4
- package/template/src/server/module-order/routes/orders-mock-routes.ts +3 -0
- package/template/src/server/module-order/services/order-service.ts +25 -13
- package/template/src/server/module-permission/__tests__/audit-log-service.test.ts +464 -0
- package/template/src/server/module-permission/__tests__/role-service.test.ts +348 -0
- package/template/src/server/module-permission/routes/audit-log-routes.ts +3 -0
- package/template/src/server/module-permission/routes/permission-routes.ts +3 -0
- package/template/src/server/module-permission/routes/role-routes.ts +3 -0
- package/template/src/server/module-plugin/routes/plugin-admin-routes.ts +3 -0
- package/template/src/server/module-plugin/routes/plugin-routes.ts +3 -0
- package/template/src/server/module-plugin/services/admin-plugin-service.ts +10 -18
- package/template/src/server/module-plugin/services/admin-stats-service.ts +28 -9
- package/template/src/server/module-plugin/services/plugin-query-service.ts +42 -66
- package/template/src/server/module-tenant/routes/tenant-routes.ts +5 -1
- package/template/src/server/module-ticket/__tests__/ticket-route.test.ts +2 -1
- package/template/src/server/module-ticket/__tests__/ticket-service.test.ts +4 -3
- package/template/src/server/module-ticket/routes/ticket-routes.ts +11 -10
- package/template/src/server/module-ticket/services/ticket-service.ts +16 -5
- package/template/src/server/module-todos/__tests__/isr.test.ts +105 -0
- package/template/src/server/module-todos/__tests__/todo-service.test.ts +12 -9
- package/template/src/server/module-todos/__tests__/todos-route-rpc.test.ts +6 -6
- package/template/src/server/module-todos/isr.ts +41 -0
- package/template/src/server/module-todos/routes/todos-routes.ts +12 -5
- package/template/src/server/module-todos/services/todo-service.ts +31 -10
- package/template/src/server/route-registry.ts +0 -4
- package/template/src/server/rpc-merge.ts +27 -0
- package/template/src/server/rpc-surface.ts +117 -0
- package/template/src/server/rpc-type-canary.ts +80 -0
- package/template/src/server/test-utils/test-client.ts +7 -9
- package/template/src/server/test-utils/test-isr-helper.ts +140 -0
- package/template/src/shared/modules/content/schemas.ts +14 -0
- package/template/src/shared/modules/dispute/schemas.ts +14 -0
- package/template/src/shared/modules/order/schemas.ts +9 -1
- package/template/src/shared/modules/ticket/schemas.ts +14 -0
- package/template/src/shared/modules/todos/index.ts +4 -0
- package/template/src/shared/modules/todos/schemas.ts +14 -0
- package/template/src/shared/schemas/index.ts +18 -0
- package/template/tsup.config.ts +48 -1
- package/template/vitest.config.ts +19 -3
- package/template/vitest.setup.ts +68 -5
- package/template/drizzle/0000_rainy_boomer.sql +0 -101
- package/template/drizzle/0001_add_todo_attachments.sql +0 -12
- package/template/drizzle/0002_chilly_magneto.sql +0 -89
- package/template/drizzle/0003_ambiguous_magdalene.sql +0 -100
- package/template/drizzle/0004_add_merchants_products.sql +0 -30
- package/template/drizzle/meta/0000_snapshot.json +0 -652
- package/template/drizzle/meta/0001_snapshot.json +0 -735
- package/template/drizzle/meta/0002_snapshot.json +0 -1198
- package/template/drizzle/meta/0003_snapshot.json +0 -1837
- package/template/drizzle/meta/_journal.json +0 -41
- package/template/patches/typescript+5.9.3.patch +0 -24
- package/template/pnpm-lock.yaml +0 -7137
- /package/template/patches/{hono+4.12.16.patch → hono+4.12.34.patch} +0 -0
package/template/vitest.setup.ts
CHANGED
|
@@ -4,12 +4,75 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { afterEach, vi } from 'vitest'
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// jest-dom 仅客户端组件测试需要;无 client 的 preset 未安装
|
|
8
|
+
const jestDomPkg = '@testing-library/jest-dom'
|
|
9
|
+
try {
|
|
10
|
+
await import(/* @vite-ignore */ jestDomPkg)
|
|
11
|
+
} catch {
|
|
12
|
+
// preset 无该依赖
|
|
13
|
+
}
|
|
14
|
+
// eventsource 仅客户端测试需要;无 client 的 preset 未安装该依赖。
|
|
15
|
+
// createRequire 放在块内避免与下方同名工具冲突
|
|
16
|
+
let EventSourceCtor: unknown = class {} as unknown
|
|
17
|
+
try {
|
|
18
|
+
const { createRequire: cr } = await import('node:module')
|
|
19
|
+
const req = cr(import.meta.url)
|
|
20
|
+
EventSourceCtor = req('eventsource').EventSource
|
|
21
|
+
} catch {
|
|
22
|
+
// preset 无该依赖
|
|
23
|
+
}
|
|
24
|
+
import { createRequire } from 'node:module'
|
|
25
|
+
|
|
26
|
+
// admin i18n 语言包仅存在于含 admin 模块的 preset(如 fullstack-admin);
|
|
27
|
+
// 不含 admin 的 preset(如 todo-app/minimal)没有该文件,缺省回退到 key 本身。
|
|
28
|
+
const require = createRequire(import.meta.url)
|
|
29
|
+
let zhCN: Record<string, unknown> = {}
|
|
30
|
+
try {
|
|
31
|
+
zhCN = (require('./src/admin/i18n/locales/zh-CN.json') as Record<string, unknown>) ?? {}
|
|
32
|
+
} catch {
|
|
33
|
+
zhCN = {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resolveTranslation(obj: Record<string, unknown>, key: string): string {
|
|
37
|
+
const keys = key.split('.')
|
|
38
|
+
let current: unknown = obj
|
|
39
|
+
for (const k of keys) {
|
|
40
|
+
if (current && typeof current === 'object' && k in (current as Record<string, unknown>)) {
|
|
41
|
+
current = (current as Record<string, unknown>)[k]
|
|
42
|
+
} else {
|
|
43
|
+
return key
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return typeof current === 'string' ? current : key
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const stableT = (key: string, params?: Record<string, unknown>) => {
|
|
50
|
+
let val = resolveTranslation(zhCN, key)
|
|
51
|
+
if (params) {
|
|
52
|
+
for (const [k, v] of Object.entries(params)) {
|
|
53
|
+
val = val.replace(`{{${k}}}`, String(v))
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return val
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
vi.mock('react-i18next', () => ({
|
|
60
|
+
useTranslation: () => ({
|
|
61
|
+
t: stableT,
|
|
62
|
+
i18n: {
|
|
63
|
+
language: 'zh-CN',
|
|
64
|
+
changeLanguage: () => {},
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
initReactI18next: {
|
|
68
|
+
type: '3rdParty',
|
|
69
|
+
init: () => {},
|
|
70
|
+
},
|
|
71
|
+
}))
|
|
9
72
|
|
|
10
73
|
vi.mock('react-helmet-async', () => ({
|
|
11
|
-
Helmet: ({ children }: { children
|
|
12
|
-
HelmetProvider: ({ children }: { children
|
|
74
|
+
Helmet: ({ children }: { children?: unknown }) => children,
|
|
75
|
+
HelmetProvider: ({ children }: { children?: unknown }) => children,
|
|
13
76
|
}))
|
|
14
77
|
|
|
15
78
|
afterEach(() => {})
|
|
@@ -63,7 +126,7 @@ console.warn = (...args: unknown[]) => {
|
|
|
63
126
|
}
|
|
64
127
|
|
|
65
128
|
// EventSource can be used in both environments
|
|
66
|
-
global.EventSource =
|
|
129
|
+
global.EventSource = EventSourceCtor as unknown as typeof globalThis.EventSource
|
|
67
130
|
|
|
68
131
|
if (typeof globalThis.WebSocket === 'undefined') {
|
|
69
132
|
class MockWebSocket {
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `todos` (
|
|
2
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
-
`title` text NOT NULL,
|
|
4
|
-
`description` text,
|
|
5
|
-
`status` text DEFAULT 'pending' NOT NULL,
|
|
6
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
7
|
-
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
8
|
-
);
|
|
9
|
-
--> statement-breakpoint
|
|
10
|
-
CREATE TABLE `notifications` (
|
|
11
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
12
|
-
`type` text NOT NULL,
|
|
13
|
-
`title` text NOT NULL,
|
|
14
|
-
`message` text NOT NULL,
|
|
15
|
-
`read` integer DEFAULT false NOT NULL,
|
|
16
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
17
|
-
);
|
|
18
|
-
--> statement-breakpoint
|
|
19
|
-
CREATE TABLE `permissions` (
|
|
20
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
21
|
-
`code` text NOT NULL,
|
|
22
|
-
`name` text NOT NULL,
|
|
23
|
-
`label` text NOT NULL,
|
|
24
|
-
`category` text NOT NULL,
|
|
25
|
-
`description` text,
|
|
26
|
-
`sort_order` integer DEFAULT 0,
|
|
27
|
-
`is_active` integer DEFAULT true,
|
|
28
|
-
`created_at` integer,
|
|
29
|
-
`updated_at` integer
|
|
30
|
-
);
|
|
31
|
-
--> statement-breakpoint
|
|
32
|
-
CREATE UNIQUE INDEX `permissions_code_unique` ON `permissions` (`code`);--> statement-breakpoint
|
|
33
|
-
CREATE TABLE `roles` (
|
|
34
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
35
|
-
`code` text NOT NULL,
|
|
36
|
-
`name` text NOT NULL,
|
|
37
|
-
`label` text NOT NULL,
|
|
38
|
-
`description` text,
|
|
39
|
-
`is_system` integer DEFAULT false,
|
|
40
|
-
`is_active` integer DEFAULT true,
|
|
41
|
-
`sort_order` integer DEFAULT 0,
|
|
42
|
-
`created_at` integer,
|
|
43
|
-
`updated_at` integer
|
|
44
|
-
);
|
|
45
|
-
--> statement-breakpoint
|
|
46
|
-
CREATE UNIQUE INDEX `roles_code_unique` ON `roles` (`code`);--> statement-breakpoint
|
|
47
|
-
CREATE TABLE `role_permissions` (
|
|
48
|
-
`role_id` text NOT NULL,
|
|
49
|
-
`permission_id` text NOT NULL,
|
|
50
|
-
`created_at` integer,
|
|
51
|
-
PRIMARY KEY(`role_id`, `permission_id`),
|
|
52
|
-
FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
53
|
-
FOREIGN KEY (`permission_id`) REFERENCES `permissions`(`id`) ON UPDATE no action ON DELETE cascade
|
|
54
|
-
);
|
|
55
|
-
--> statement-breakpoint
|
|
56
|
-
CREATE TABLE `user_roles` (
|
|
57
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
58
|
-
`user_id` text NOT NULL,
|
|
59
|
-
`role_id` text NOT NULL,
|
|
60
|
-
`assigned_by` text,
|
|
61
|
-
`assigned_at` integer,
|
|
62
|
-
`expires_at` integer,
|
|
63
|
-
`is_active` integer DEFAULT true,
|
|
64
|
-
FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON UPDATE no action ON DELETE cascade
|
|
65
|
-
);
|
|
66
|
-
--> statement-breakpoint
|
|
67
|
-
CREATE TABLE `routes` (
|
|
68
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
69
|
-
`path` text NOT NULL,
|
|
70
|
-
`method` text NOT NULL,
|
|
71
|
-
`name` text,
|
|
72
|
-
`description` text,
|
|
73
|
-
`module` text,
|
|
74
|
-
`is_public` integer DEFAULT false,
|
|
75
|
-
`is_active` integer DEFAULT true,
|
|
76
|
-
`created_at` integer,
|
|
77
|
-
`updated_at` integer
|
|
78
|
-
);
|
|
79
|
-
--> statement-breakpoint
|
|
80
|
-
CREATE UNIQUE INDEX `routes_path_method_unique` ON `routes` (`path`,`method`);--> statement-breakpoint
|
|
81
|
-
CREATE TABLE `permission_routes` (
|
|
82
|
-
`permission_id` text NOT NULL,
|
|
83
|
-
`route_id` text NOT NULL,
|
|
84
|
-
`created_at` integer,
|
|
85
|
-
PRIMARY KEY(`permission_id`, `route_id`),
|
|
86
|
-
FOREIGN KEY (`permission_id`) REFERENCES `permissions`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
87
|
-
FOREIGN KEY (`route_id`) REFERENCES `routes`(`id`) ON UPDATE no action ON DELETE cascade
|
|
88
|
-
);
|
|
89
|
-
--> statement-breakpoint
|
|
90
|
-
CREATE TABLE `permission_audit_logs` (
|
|
91
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
92
|
-
`user_id` text NOT NULL,
|
|
93
|
-
`action` text NOT NULL,
|
|
94
|
-
`resource_type` text NOT NULL,
|
|
95
|
-
`resource_id` text,
|
|
96
|
-
`old_value` text,
|
|
97
|
-
`new_value` text,
|
|
98
|
-
`ip_address` text,
|
|
99
|
-
`user_agent` text,
|
|
100
|
-
`created_at` integer
|
|
101
|
-
);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `todo_attachments` (
|
|
2
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
-
`todo_id` integer NOT NULL,
|
|
4
|
-
`file_name` text NOT NULL,
|
|
5
|
-
`original_name` text NOT NULL,
|
|
6
|
-
`mime_type` text NOT NULL,
|
|
7
|
-
`size` integer NOT NULL,
|
|
8
|
-
`path` text NOT NULL,
|
|
9
|
-
`uploaded_by` text,
|
|
10
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
11
|
-
FOREIGN KEY (`todo_id`) REFERENCES `todos`(`id`) ON UPDATE no action ON DELETE cascade
|
|
12
|
-
);
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `orders` (
|
|
2
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
-
`order_no` text NOT NULL,
|
|
4
|
-
`customer_name` text NOT NULL,
|
|
5
|
-
`customer_email` text NOT NULL,
|
|
6
|
-
`product_name` text NOT NULL,
|
|
7
|
-
`amount` integer NOT NULL,
|
|
8
|
-
`status` text DEFAULT 'pending' NOT NULL,
|
|
9
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
10
|
-
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
11
|
-
);
|
|
12
|
-
--> statement-breakpoint
|
|
13
|
-
CREATE TABLE `ticket_replies` (
|
|
14
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
15
|
-
`ticket_id` integer NOT NULL,
|
|
16
|
-
`content` text NOT NULL,
|
|
17
|
-
`author` text NOT NULL,
|
|
18
|
-
`is_customer` integer DEFAULT false NOT NULL,
|
|
19
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
20
|
-
FOREIGN KEY (`ticket_id`) REFERENCES `tickets`(`id`) ON UPDATE no action ON DELETE cascade
|
|
21
|
-
);
|
|
22
|
-
--> statement-breakpoint
|
|
23
|
-
CREATE TABLE `tickets` (
|
|
24
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
25
|
-
`ticket_no` text NOT NULL,
|
|
26
|
-
`customer_name` text NOT NULL,
|
|
27
|
-
`customer_email` text NOT NULL,
|
|
28
|
-
`subject` text NOT NULL,
|
|
29
|
-
`description` text NOT NULL,
|
|
30
|
-
`status` text DEFAULT 'open' NOT NULL,
|
|
31
|
-
`priority` text DEFAULT 'medium' NOT NULL,
|
|
32
|
-
`category` text NOT NULL,
|
|
33
|
-
`assigned_to` text,
|
|
34
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
35
|
-
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
36
|
-
);
|
|
37
|
-
--> statement-breakpoint
|
|
38
|
-
CREATE TABLE `disputes` (
|
|
39
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
40
|
-
`dispute_no` text NOT NULL,
|
|
41
|
-
`order_id` text NOT NULL,
|
|
42
|
-
`order_no` text NOT NULL,
|
|
43
|
-
`customer_name` text NOT NULL,
|
|
44
|
-
`customer_email` text NOT NULL,
|
|
45
|
-
`type` text NOT NULL,
|
|
46
|
-
`status` text DEFAULT 'pending' NOT NULL,
|
|
47
|
-
`description` text NOT NULL,
|
|
48
|
-
`resolution` text,
|
|
49
|
-
`amount` integer NOT NULL,
|
|
50
|
-
`resolved_at` integer,
|
|
51
|
-
`resolved_by` text,
|
|
52
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
53
|
-
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
54
|
-
);
|
|
55
|
-
--> statement-breakpoint
|
|
56
|
-
CREATE TABLE `contents` (
|
|
57
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
58
|
-
`title` text NOT NULL,
|
|
59
|
-
`body` text NOT NULL,
|
|
60
|
-
`excerpt` text,
|
|
61
|
-
`category` text NOT NULL,
|
|
62
|
-
`tags` text,
|
|
63
|
-
`status` text DEFAULT 'draft' NOT NULL,
|
|
64
|
-
`author` text NOT NULL,
|
|
65
|
-
`view_count` integer DEFAULT 0 NOT NULL,
|
|
66
|
-
`like_count` integer DEFAULT 0 NOT NULL,
|
|
67
|
-
`published_at` integer,
|
|
68
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
69
|
-
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
70
|
-
);
|
|
71
|
-
--> statement-breakpoint
|
|
72
|
-
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
|
73
|
-
CREATE TABLE `__new_todo_attachments` (
|
|
74
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
75
|
-
`todo_id` integer NOT NULL,
|
|
76
|
-
`file_name` text NOT NULL,
|
|
77
|
-
`original_name` text NOT NULL,
|
|
78
|
-
`mime_type` text NOT NULL,
|
|
79
|
-
`size` integer NOT NULL,
|
|
80
|
-
`path` text NOT NULL,
|
|
81
|
-
`uploaded_by` text,
|
|
82
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
83
|
-
FOREIGN KEY (`todo_id`) REFERENCES `todos`(`id`) ON UPDATE no action ON DELETE cascade
|
|
84
|
-
);
|
|
85
|
-
--> statement-breakpoint
|
|
86
|
-
INSERT INTO `__new_todo_attachments`("id", "todo_id", "file_name", "original_name", "mime_type", "size", "path", "uploaded_by", "created_at") SELECT "id", "todo_id", "file_name", "original_name", "mime_type", "size", "path", "uploaded_by", "created_at" FROM `todo_attachments`;--> statement-breakpoint
|
|
87
|
-
DROP TABLE `todo_attachments`;--> statement-breakpoint
|
|
88
|
-
ALTER TABLE `__new_todo_attachments` RENAME TO `todo_attachments`;--> statement-breakpoint
|
|
89
|
-
PRAGMA foreign_keys=ON;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
CREATE TABLE `developers` (
|
|
2
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
-
`username` text NOT NULL,
|
|
4
|
-
`email` text NOT NULL,
|
|
5
|
-
`password_hash` text NOT NULL,
|
|
6
|
-
`role` text DEFAULT 'developer' NOT NULL,
|
|
7
|
-
`api_key` text NOT NULL,
|
|
8
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
9
|
-
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
10
|
-
);
|
|
11
|
-
--> statement-breakpoint
|
|
12
|
-
CREATE UNIQUE INDEX `developers_username_unique` ON `developers` (`username`);--> statement-breakpoint
|
|
13
|
-
CREATE UNIQUE INDEX `developers_email_unique` ON `developers` (`email`);--> statement-breakpoint
|
|
14
|
-
CREATE UNIQUE INDEX `developers_api_key_unique` ON `developers` (`api_key`);--> statement-breakpoint
|
|
15
|
-
CREATE TABLE `plugin_categories` (
|
|
16
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
17
|
-
`name` text NOT NULL,
|
|
18
|
-
`slug` text NOT NULL,
|
|
19
|
-
`description` text,
|
|
20
|
-
`icon` text,
|
|
21
|
-
`sort_order` integer DEFAULT 0 NOT NULL
|
|
22
|
-
);
|
|
23
|
-
--> statement-breakpoint
|
|
24
|
-
CREATE UNIQUE INDEX `plugin_categories_name_unique` ON `plugin_categories` (`name`);--> statement-breakpoint
|
|
25
|
-
CREATE UNIQUE INDEX `plugin_categories_slug_unique` ON `plugin_categories` (`slug`);--> statement-breakpoint
|
|
26
|
-
CREATE TABLE `plugin_category_mappings` (
|
|
27
|
-
`plugin_id` text NOT NULL,
|
|
28
|
-
`category_id` text NOT NULL,
|
|
29
|
-
FOREIGN KEY (`plugin_id`) REFERENCES `plugins`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
30
|
-
FOREIGN KEY (`category_id`) REFERENCES `plugin_categories`(`id`) ON UPDATE no action ON DELETE cascade
|
|
31
|
-
);
|
|
32
|
-
--> statement-breakpoint
|
|
33
|
-
CREATE UNIQUE INDEX `plugin_category_mapping_unique` ON `plugin_category_mappings` (`plugin_id`,`category_id`);--> statement-breakpoint
|
|
34
|
-
CREATE TABLE `plugin_reviews` (
|
|
35
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
36
|
-
`plugin_id` text NOT NULL,
|
|
37
|
-
`user_id` text NOT NULL,
|
|
38
|
-
`user_name` text NOT NULL,
|
|
39
|
-
`rating` integer NOT NULL,
|
|
40
|
-
`title` text,
|
|
41
|
-
`content` text,
|
|
42
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
43
|
-
FOREIGN KEY (`plugin_id`) REFERENCES `plugins`(`id`) ON UPDATE no action ON DELETE cascade
|
|
44
|
-
);
|
|
45
|
-
--> statement-breakpoint
|
|
46
|
-
CREATE UNIQUE INDEX `plugin_review_user_unique` ON `plugin_reviews` (`plugin_id`,`user_id`);--> statement-breakpoint
|
|
47
|
-
CREATE TABLE `plugin_versions` (
|
|
48
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
49
|
-
`plugin_id` text NOT NULL,
|
|
50
|
-
`version` text NOT NULL,
|
|
51
|
-
`changelog` text,
|
|
52
|
-
`package_url` text,
|
|
53
|
-
`file_size` integer,
|
|
54
|
-
`checksum` text,
|
|
55
|
-
`status` text DEFAULT 'pending' NOT NULL,
|
|
56
|
-
`published_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
57
|
-
FOREIGN KEY (`plugin_id`) REFERENCES `plugins`(`id`) ON UPDATE no action ON DELETE cascade
|
|
58
|
-
);
|
|
59
|
-
--> statement-breakpoint
|
|
60
|
-
CREATE UNIQUE INDEX `plugin_version_unique` ON `plugin_versions` (`plugin_id`,`version`);--> statement-breakpoint
|
|
61
|
-
CREATE TABLE `plugins` (
|
|
62
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
63
|
-
`name` text NOT NULL,
|
|
64
|
-
`slug` text NOT NULL,
|
|
65
|
-
`description` text DEFAULT '' NOT NULL,
|
|
66
|
-
`readme` text,
|
|
67
|
-
`author_id` text NOT NULL,
|
|
68
|
-
`author_name` text NOT NULL,
|
|
69
|
-
`repository_url` text,
|
|
70
|
-
`homepage_url` text,
|
|
71
|
-
`npm_package` text,
|
|
72
|
-
`license` text,
|
|
73
|
-
`version` text DEFAULT '0.0.1' NOT NULL,
|
|
74
|
-
`status` text DEFAULT 'pending' NOT NULL,
|
|
75
|
-
`download_count` integer DEFAULT 0 NOT NULL,
|
|
76
|
-
`view_count` integer DEFAULT 0 NOT NULL,
|
|
77
|
-
`featured` integer DEFAULT false NOT NULL,
|
|
78
|
-
`screenshot_url` text,
|
|
79
|
-
`site_urls` text,
|
|
80
|
-
`tags` text,
|
|
81
|
-
`commands` text,
|
|
82
|
-
`reject_reason` text,
|
|
83
|
-
`created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
|
|
84
|
-
`updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
|
|
85
|
-
);
|
|
86
|
-
--> statement-breakpoint
|
|
87
|
-
CREATE UNIQUE INDEX `plugins_slug_unique` ON `plugins` (`slug`);--> statement-breakpoint
|
|
88
|
-
CREATE TABLE `tenants` (
|
|
89
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
90
|
-
`name` text NOT NULL,
|
|
91
|
-
`slug` text NOT NULL,
|
|
92
|
-
`status` text DEFAULT 'trial' NOT NULL,
|
|
93
|
-
`plan` text DEFAULT 'free' NOT NULL,
|
|
94
|
-
`max_users` integer DEFAULT 5 NOT NULL,
|
|
95
|
-
`settings` text,
|
|
96
|
-
`created_at` text NOT NULL,
|
|
97
|
-
`updated_at` text NOT NULL
|
|
98
|
-
);
|
|
99
|
-
--> statement-breakpoint
|
|
100
|
-
CREATE UNIQUE INDEX `tenants_slug_unique` ON `tenants` (`slug`);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
-- Create merchants table
|
|
2
|
-
CREATE TABLE `merchants` (
|
|
3
|
-
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
4
|
-
`user_id` text NOT NULL,
|
|
5
|
-
`tenant_id` integer NOT NULL,
|
|
6
|
-
`business_name` text NOT NULL,
|
|
7
|
-
`business_type` text NOT NULL,
|
|
8
|
-
`status` text NOT NULL DEFAULT 'active',
|
|
9
|
-
`description` text,
|
|
10
|
-
`phone` text,
|
|
11
|
-
`email` text,
|
|
12
|
-
`address` text,
|
|
13
|
-
`password` text NOT NULL,
|
|
14
|
-
`created_at` text NOT NULL,
|
|
15
|
-
`updated_at` text NOT NULL
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
-- Create products table
|
|
19
|
-
CREATE TABLE `products` (
|
|
20
|
-
`id` text PRIMARY KEY NOT NULL,
|
|
21
|
-
`merchant_id` integer NOT NULL,
|
|
22
|
-
`name` text NOT NULL,
|
|
23
|
-
`description` text,
|
|
24
|
-
`price` real NOT NULL,
|
|
25
|
-
`status` text NOT NULL DEFAULT 'active',
|
|
26
|
-
`stock` integer NOT NULL DEFAULT 0,
|
|
27
|
-
`image_url` text,
|
|
28
|
-
`created_at` integer NOT NULL,
|
|
29
|
-
`updated_at` integer NOT NULL
|
|
30
|
-
);
|