Skip to content

Commit

Permalink
✨ refactor(db/migration): Organize SQL migration scripts and enhanc…
Browse files Browse the repository at this point in the history
…e zhparser extension setup with additional configurations and custom word initialization.
  • Loading branch information
vnobo committed Feb 24, 2025
1 parent b6633a2 commit 8e08117
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
-- create the extension
create extension zhparser;
create extension if not exists zhparser;

-- make test configuration using parser
drop text search configuration if exists chinese cascade;
create text search configuration chinese (parser = zhparser);

-- add token mapping
alter text search configuration chinese add mapping for n,v,a,i,e,l,x with simple;
set default_text_search_config = 'chinese';
show default_text_search_config;
truncate table zhparser.zhprs_custom_word;
--add custom word
insert into zhparser.zhprs_custom_word
values ('支付宝');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
do
$do$
declare
v_code varchar(32);
v_phone varchar(32);
batch_size INTEGER := 10000;
batch_count INTEGER := 0;
begin
for i in 1..100000
loop
-- 生成用户代码
if i < 1000 then
v_code := 'U' || lpad(i::text, 4, '0');
else
v_code := 'U' || (i + 3)::text;
end if;

-- 生成手机号码
v_phone := '1708911826' || lpad(i::text, 2, '0');

-- 插入用户数据
insert into se_users(code, username, password, name, phone, email, bio, creator, updater)
values (gen_random_uuid(), 'user' || i,
'{pbkdf2}7d8a68bc5d507bd19bc153ff10bcdef66f5a5f3d0c1ab2438630e50b5c65894bccc2c7e4404c5afa',
'普通用户' || i, v_phone, 'user' || i || '@qq.com', null,
'f47ac10b-58cc-4372-a567-0e02b2c3d479', 'f47ac10b-58cc-4372-a567-0e02b2c3d479');
batch_count := batch_count + 1;
if (batch_count % batch_size = 0) then
commit;
end if;
end loop;
commit;
end;
$do$;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
executeInTransaction=false

0 comments on commit 8e08117

Please sign in to comment.