30 lines
1.2 KiB
SQL
30 lines
1.2 KiB
SQL
-- ----------------------------
|
|
-- 发票表结构更新脚本 (PostgreSQL)
|
|
-- 说明:此脚本用于为发票表添加发票号码、结算关联和税率字段
|
|
-- 请根据实际情况谨慎执行,建议先备份数据
|
|
-- ----------------------------
|
|
|
|
-- ----------------------------
|
|
-- 第一步:备份原有数据(可选,建议执行)
|
|
-- ----------------------------
|
|
-- 创建备份表
|
|
-- create table biz_invoice_backup as select * from biz_invoice;
|
|
|
|
-- ----------------------------
|
|
-- 第二步:添加发票号码字段
|
|
-- ----------------------------
|
|
alter table biz_invoice add column if not exists invoice_no varchar(100) default null;
|
|
|
|
-- ----------------------------
|
|
-- 第三步:添加结算关联和税率字段
|
|
-- ----------------------------
|
|
alter table biz_invoice add column if not exists settlement_id bigint(20) default null;
|
|
alter table biz_invoice add column if not exists tax_rate varchar(10) default null;
|
|
|
|
-- ----------------------------
|
|
-- 第四步:添加字段注释
|
|
-- ----------------------------
|
|
comment on column biz_invoice.invoice_no is '发票号码';
|
|
comment on column biz_invoice.settlement_id is '结算ID';
|
|
comment on column biz_invoice.tax_rate is '税率(1:6%+2% 2:10%+2% 3:13%+2%)';
|