From ebaf9b0b050f973ee29c42bbdec2bf3e06af3d33 Mon Sep 17 00:00:00 2001 From: "Eric 1549169735@qq.com" <1549169735@qq.com> Date: Wed, 19 Aug 2026 22:55:07 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BC=98=E5=8C=96build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 - go.sum | 61 +---- internal/migration/migration.go | 35 --- migrations/000001_init.down.sql | 17 -- migrations/000001_init.up.sql | 258 ------------------ .../000002_bind_knowledge_versions.down.sql | 4 - .../000002_bind_knowledge_versions.up.sql | 25 -- migrations/000003_multitable_outbox.down.sql | 1 - migrations/000003_multitable_outbox.up.sql | 23 -- .../000004_remove_review_workflow.down.sql | 1 - .../000004_remove_review_workflow.up.sql | 15 - .../000005_generic_scenario_runtime.down.sql | 4 - .../000005_generic_scenario_runtime.up.sql | 20 -- migrations/000006_knowledge_graph.down.sql | 2 - migrations/000006_knowledge_graph.up.sql | 38 --- migrations/000007_public_sdk_access.down.sql | 3 - migrations/000007_public_sdk_access.up.sql | 31 --- migrations/000008_scenario_rules.down.sql | 1 - migrations/000008_scenario_rules.up.sql | 18 -- .../000009_run_knowledge_snapshot.down.sql | 1 - .../000009_run_knowledge_snapshot.up.sql | 3 - .../000010_scenario_final_result.down.sql | 2 - .../000010_scenario_final_result.up.sql | 8 - 23 files changed, 4 insertions(+), 571 deletions(-) delete mode 100644 internal/migration/migration.go delete mode 100644 migrations/000001_init.down.sql delete mode 100644 migrations/000001_init.up.sql delete mode 100644 migrations/000002_bind_knowledge_versions.down.sql delete mode 100644 migrations/000002_bind_knowledge_versions.up.sql delete mode 100644 migrations/000003_multitable_outbox.down.sql delete mode 100644 migrations/000003_multitable_outbox.up.sql delete mode 100644 migrations/000004_remove_review_workflow.down.sql delete mode 100644 migrations/000004_remove_review_workflow.up.sql delete mode 100644 migrations/000005_generic_scenario_runtime.down.sql delete mode 100644 migrations/000005_generic_scenario_runtime.up.sql delete mode 100644 migrations/000006_knowledge_graph.down.sql delete mode 100644 migrations/000006_knowledge_graph.up.sql delete mode 100644 migrations/000007_public_sdk_access.down.sql delete mode 100644 migrations/000007_public_sdk_access.up.sql delete mode 100644 migrations/000008_scenario_rules.down.sql delete mode 100644 migrations/000008_scenario_rules.up.sql delete mode 100644 migrations/000009_run_knowledge_snapshot.down.sql delete mode 100644 migrations/000009_run_knowledge_snapshot.up.sql delete mode 100644 migrations/000010_scenario_final_result.down.sql delete mode 100644 migrations/000010_scenario_final_result.up.sql diff --git a/go.mod b/go.mod index 5736476..4a34bc6 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.24 require ( github.com/gin-gonic/gin v1.10.0 github.com/golang-jwt/jwt/v5 v5.2.2 - github.com/golang-migrate/migrate/v4 v4.18.2 github.com/google/uuid v1.6.0 github.com/ilyakaznacheev/cleanenv v1.5.0 github.com/xuri/excelize/v2 v2.9.0 @@ -30,8 +29,6 @@ require ( github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/go-sql-driver/mysql v1.8.1 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/joho/godotenv v1.5.1 // indirect @@ -50,7 +47,6 @@ require ( github.com/ugorji/go/codec v1.2.12 // indirect github.com/xuri/efp v0.0.1 // indirect github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect - go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/arch v0.8.0 // indirect golang.org/x/net v0.33.0 // indirect diff --git a/go.sum b/go.sum index b60f8e1..3a14bc4 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,7 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= -github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= -github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= @@ -17,28 +13,12 @@ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dhui/dktest v0.4.4 h1:+I4s6JRE1yGuqflzwqG+aIaMdgXIorCf5P98JnaAWa8= -github.com/dhui/dktest v0.4.4/go.mod h1:4+22R4lgsdAXrDyaH4Nqx2JEz2hLp49MqQmm9HLCQhM= -github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= -github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v27.2.0+incompatible h1:Rk9nIVdfH3+Vz4cyI/uhbINhEZ/oLmc+CBXmH6fbNk4= -github.com/docker/docker v27.2.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= -github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= -github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= -github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -52,12 +32,8 @@ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpv github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/golang-migrate/migrate/v4 v4.18.2 h1:2VSCMz7x7mjyTXx3m2zPokOY82LTRgxK1yQYKo6wWQ8= -github.com/golang-migrate/migrate/v4 v4.18.2/go.mod h1:2CM6tJvn2kqPXwnXO/d3rAQYiyoIm180VsO8PRX6Rpk= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= @@ -67,11 +43,6 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/ilyakaznacheev/cleanenv v1.5.0 h1:0VNZXggJE2OYdXE87bfSSwGxeiGt9moSR2lOrsHHvr4= github.com/ilyakaznacheev/cleanenv v1.5.0/go.mod h1:a5aDzaJrLCQZsazHol1w8InnDcOX0OColm64SlIi6gk= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= @@ -96,18 +67,12 @@ github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZY github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= -github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= -github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= +github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA= github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= -github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= -github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -115,16 +80,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= -github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/richardlehane/mscfb v1.0.7 h1:oeoiM0WE79vHwE8RpIYYvIAc8ajTH2mb6UZm55/+EB0= @@ -154,16 +111,6 @@ github.com/xuri/excelize/v2 v2.9.0 h1:1tgOaEq92IOEumR1/JfYS/eR0KHOCsRv/rYXXh6YJQ github.com/xuri/excelize/v2 v2.9.0/go.mod h1:uqey4QBZ9gdMeWApPLdhm9x+9o2lq4iVmjiLfBS5hdE= github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 h1:+C0TIdyyYmzadGaL/HBLbf3WdLgC29pgyhTjAT/0nuE= github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= -go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= -go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= -go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= -go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= -go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= -go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= @@ -187,8 +134,8 @@ golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/internal/migration/migration.go b/internal/migration/migration.go deleted file mode 100644 index d5cd133..0000000 --- a/internal/migration/migration.go +++ /dev/null @@ -1,35 +0,0 @@ -package migration - -import ( - "errors" - "fmt" - "io/fs" - - "github.com/golang-migrate/migrate/v4" - migratemysql "github.com/golang-migrate/migrate/v4/database/mysql" - "github.com/golang-migrate/migrate/v4/source/iofs" - "gorm.io/gorm" -) - -func Run(db *gorm.DB, files fs.FS) error { - sqlDB, err := db.DB() - if err != nil { - return fmt.Errorf("get sql database: %w", err) - } - driver, err := migratemysql.WithInstance(sqlDB, &migratemysql.Config{}) - if err != nil { - return fmt.Errorf("create migration database driver: %w", err) - } - source, err := iofs.New(files, "migrations") - if err != nil { - return fmt.Errorf("create migration source: %w", err) - } - m, err := migrate.NewWithInstance("iofs", source, "mysql", driver) - if err != nil { - return fmt.Errorf("create migrator: %w", err) - } - if err := m.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) { - return fmt.Errorf("run migrations: %w", err) - } - return nil -} diff --git a/migrations/000001_init.down.sql b/migrations/000001_init.down.sql deleted file mode 100644 index 8d71cf1..0000000 --- a/migrations/000001_init.down.sql +++ /dev/null @@ -1,17 +0,0 @@ -DROP TABLE IF EXISTS refresh_tokens; -DROP TABLE IF EXISTS audit_logs; -DROP TABLE IF EXISTS sop_feedback; -DROP TABLE IF EXISTS sop_run_events; -DROP TABLE IF EXISTS sop_runs; -DROP TABLE IF EXISTS knowledge_card_versions; -DROP TABLE IF EXISTS knowledge_cards; -DROP TABLE IF EXISTS sop_edges; -DROP TABLE IF EXISTS sop_nodes; -DROP TABLE IF EXISTS sop_versions; -DROP TABLE IF EXISTS sops; -DROP TABLE IF EXISTS scenario_fields; -DROP TABLE IF EXISTS scenarios; -DROP TABLE IF EXISTS tenant_members; -DROP TABLE IF EXISTS roles; -DROP TABLE IF EXISTS users; -DROP TABLE IF EXISTS tenants; diff --git a/migrations/000001_init.up.sql b/migrations/000001_init.up.sql deleted file mode 100644 index b5fbca7..0000000 --- a/migrations/000001_init.up.sql +++ /dev/null @@ -1,258 +0,0 @@ -CREATE TABLE tenants ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - name VARCHAR(128) NOT NULL, - slug VARCHAR(64) NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'active', - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_tenants_slug (slug) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE users ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - username VARCHAR(64) NOT NULL, - password_hash VARCHAR(255) NOT NULL, - display_name VARCHAR(128) NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'active', - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_users_username (username) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE roles ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - name VARCHAR(64) NOT NULL, - code VARCHAR(64) NOT NULL, - permissions JSON NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_roles_tenant_code (tenant_id, code), - CONSTRAINT fk_roles_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE tenant_members ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - user_id BIGINT UNSIGNED NOT NULL, - role_id BIGINT UNSIGNED NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'active', - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_tenant_members (tenant_id, user_id), - CONSTRAINT fk_members_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_members_user FOREIGN KEY (user_id) REFERENCES users(id), - CONSTRAINT fk_members_role FOREIGN KEY (role_id) REFERENCES roles(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE scenarios ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - name VARCHAR(128) NOT NULL, - industry VARCHAR(64) NOT NULL, - role_name VARCHAR(64) NOT NULL, - goal TEXT NOT NULL, - trigger_text TEXT NOT NULL, - visibility VARCHAR(24) NOT NULL DEFAULT 'tenant', - status VARCHAR(24) NOT NULL DEFAULT 'draft', - created_by BIGINT UNSIGNED NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), KEY idx_scenarios_tenant_status (tenant_id, status), - CONSTRAINT fk_scenarios_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_scenarios_creator FOREIGN KEY (created_by) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE scenario_fields ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - scenario_id BIGINT UNSIGNED NOT NULL, - field_key VARCHAR(64) NOT NULL, - field_name VARCHAR(128) NOT NULL, - field_type VARCHAR(32) NOT NULL, - required TINYINT(1) NOT NULL DEFAULT 0, - options JSON NOT NULL, - validation JSON NOT NULL, - sort_order INT NOT NULL DEFAULT 0, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_scenario_fields_key (scenario_id, field_key), - CONSTRAINT fk_fields_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_fields_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE sops ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - scenario_id BIGINT UNSIGNED NOT NULL, - name VARCHAR(128) NOT NULL, - description TEXT NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'draft', - created_by BIGINT UNSIGNED NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), KEY idx_sops_scenario (tenant_id, scenario_id), - CONSTRAINT fk_sops_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_sops_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios(id), - CONSTRAINT fk_sops_creator FOREIGN KEY (created_by) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE sop_versions ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - sop_id BIGINT UNSIGNED NOT NULL, - version INT NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'draft', - start_node_key VARCHAR(64) NOT NULL DEFAULT '', - published_at DATETIME(3) NULL, - created_by BIGINT UNSIGNED NOT NULL, - reviewed_by BIGINT UNSIGNED NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_sop_versions (sop_id, version), - CONSTRAINT fk_versions_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_versions_sop FOREIGN KEY (sop_id) REFERENCES sops(id) ON DELETE CASCADE, - CONSTRAINT fk_versions_creator FOREIGN KEY (created_by) REFERENCES users(id), - CONSTRAINT fk_versions_reviewer FOREIGN KEY (reviewed_by) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE sop_nodes ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - sop_version_id BIGINT UNSIGNED NOT NULL, - node_key VARCHAR(64) NOT NULL, - type VARCHAR(32) NOT NULL, - title VARCHAR(128) NOT NULL, - content TEXT NOT NULL, - config JSON NOT NULL, - position_x INT NOT NULL DEFAULT 0, - position_y INT NOT NULL DEFAULT 0, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_sop_nodes_key (sop_version_id, node_key), - CONSTRAINT fk_nodes_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_nodes_version FOREIGN KEY (sop_version_id) REFERENCES sop_versions(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE sop_edges ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - sop_version_id BIGINT UNSIGNED NOT NULL, - source_node_key VARCHAR(64) NOT NULL, - target_node_key VARCHAR(64) NOT NULL, - `condition` JSON NOT NULL, - priority INT NOT NULL DEFAULT 0, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), KEY idx_sop_edges_source (sop_version_id, source_node_key, priority), - CONSTRAINT fk_edges_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_edges_version FOREIGN KEY (sop_version_id) REFERENCES sop_versions(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE knowledge_cards ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - scenario_id BIGINT UNSIGNED NOT NULL, - title VARCHAR(128) NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'draft', - created_by BIGINT UNSIGNED NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), KEY idx_cards_scenario (tenant_id, scenario_id), - CONSTRAINT fk_cards_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_cards_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios(id), - CONSTRAINT fk_cards_creator FOREIGN KEY (created_by) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE knowledge_card_versions ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - knowledge_card_id BIGINT UNSIGNED NOT NULL, - version INT NOT NULL, - content JSON NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'draft', - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_card_versions (knowledge_card_id, version), - CONSTRAINT fk_card_versions_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_card_versions_card FOREIGN KEY (knowledge_card_id) REFERENCES knowledge_cards(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE sop_runs ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - sop_id BIGINT UNSIGNED NOT NULL, - sop_version_id BIGINT UNSIGNED NOT NULL, - operator_id BIGINT UNSIGNED NOT NULL, - current_node_key VARCHAR(64) NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'running', - answers JSON NOT NULL, - result VARCHAR(64) NOT NULL DEFAULT '', - started_at DATETIME(3) NOT NULL, - completed_at DATETIME(3) NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), KEY idx_runs_tenant_status (tenant_id, status), - CONSTRAINT fk_runs_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_runs_sop FOREIGN KEY (sop_id) REFERENCES sops(id), - CONSTRAINT fk_runs_version FOREIGN KEY (sop_version_id) REFERENCES sop_versions(id), - CONSTRAINT fk_runs_operator FOREIGN KEY (operator_id) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE sop_run_events ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - run_id BIGINT UNSIGNED NOT NULL, - node_key VARCHAR(64) NOT NULL, - action VARCHAR(64) NOT NULL, - payload JSON NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), KEY idx_run_events (run_id, created_at), - CONSTRAINT fk_run_events_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_run_events_run FOREIGN KEY (run_id) REFERENCES sop_runs(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE sop_feedback ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - run_id BIGINT UNSIGNED NOT NULL, - user_id BIGINT UNSIGNED NOT NULL, - score INT NOT NULL, - comment TEXT NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_feedback_run_user (run_id, user_id), - CONSTRAINT fk_feedback_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_feedback_run FOREIGN KEY (run_id) REFERENCES sop_runs(id) ON DELETE CASCADE, - CONSTRAINT fk_feedback_user FOREIGN KEY (user_id) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE audit_logs ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - user_id BIGINT UNSIGNED NOT NULL, - action VARCHAR(64) NOT NULL, - resource VARCHAR(64) NOT NULL, - resource_id BIGINT UNSIGNED NOT NULL, - payload JSON NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), KEY idx_audit_tenant_time (tenant_id, created_at), - CONSTRAINT fk_audit_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_audit_user FOREIGN KEY (user_id) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE refresh_tokens ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - user_id BIGINT UNSIGNED NOT NULL, - token_hash VARCHAR(64) NOT NULL, - expires_at DATETIME(3) NOT NULL, - revoked_at DATETIME(3) NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), UNIQUE KEY uk_refresh_token_hash (token_hash), - CONSTRAINT fk_refresh_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_refresh_user FOREIGN KEY (user_id) REFERENCES users(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/migrations/000002_bind_knowledge_versions.down.sql b/migrations/000002_bind_knowledge_versions.down.sql deleted file mode 100644 index 3b71c61..0000000 --- a/migrations/000002_bind_knowledge_versions.down.sql +++ /dev/null @@ -1,4 +0,0 @@ -UPDATE sop_nodes -SET config = JSON_REMOVE(config, '$.knowledge_card_version_id') -WHERE type = 'knowledge' - AND JSON_EXTRACT(config, '$.knowledge_card_version_id') IS NOT NULL; diff --git a/migrations/000002_bind_knowledge_versions.up.sql b/migrations/000002_bind_knowledge_versions.up.sql deleted file mode 100644 index b146296..0000000 --- a/migrations/000002_bind_knowledge_versions.up.sql +++ /dev/null @@ -1,25 +0,0 @@ -UPDATE sop_nodes n -JOIN sop_versions sv ON sv.id = n.sop_version_id -SET n.config = JSON_SET( - n.config, - '$.knowledge_card_version_id', - ( - SELECT kv.id - FROM knowledge_card_versions kv - WHERE kv.tenant_id = n.tenant_id - AND kv.knowledge_card_id = CAST(JSON_UNQUOTE(JSON_EXTRACT(n.config, '$.knowledge_card_id')) AS UNSIGNED) - AND kv.created_at <= COALESCE(sv.published_at, sv.updated_at) - ORDER BY kv.version DESC - LIMIT 1 - ) -) -WHERE n.type = 'knowledge' - AND JSON_EXTRACT(n.config, '$.knowledge_card_version_id') IS NULL - AND JSON_EXTRACT(n.config, '$.knowledge_card_id') IS NOT NULL - AND EXISTS ( - SELECT 1 - FROM knowledge_card_versions kv - WHERE kv.tenant_id = n.tenant_id - AND kv.knowledge_card_id = CAST(JSON_UNQUOTE(JSON_EXTRACT(n.config, '$.knowledge_card_id')) AS UNSIGNED) - AND kv.created_at <= COALESCE(sv.published_at, sv.updated_at) - ); diff --git a/migrations/000003_multitable_outbox.down.sql b/migrations/000003_multitable_outbox.down.sql deleted file mode 100644 index 58d0813..0000000 --- a/migrations/000003_multitable_outbox.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS multitable_outbox; diff --git a/migrations/000003_multitable_outbox.up.sql b/migrations/000003_multitable_outbox.up.sql deleted file mode 100644 index 0d8fed9..0000000 --- a/migrations/000003_multitable_outbox.up.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE multitable_outbox ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - audit_log_id BIGINT UNSIGNED NULL, - resource VARCHAR(64) NOT NULL, - resource_id BIGINT UNSIGNED NOT NULL, - action VARCHAR(64) NOT NULL, - payload JSON NOT NULL, - dedupe_key VARCHAR(191) NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'pending', - attempts INT NOT NULL DEFAULT 0, - available_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - last_error TEXT NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), - UNIQUE KEY uk_multitable_outbox_audit (audit_log_id), - UNIQUE KEY uk_multitable_outbox_dedupe (dedupe_key), - KEY idx_multitable_outbox_pending (status, available_at), - KEY idx_multitable_outbox_resource (tenant_id, resource, resource_id), - CONSTRAINT fk_multitable_outbox_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_multitable_outbox_audit FOREIGN KEY (audit_log_id) REFERENCES audit_logs(id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/migrations/000004_remove_review_workflow.down.sql b/migrations/000004_remove_review_workflow.down.sql deleted file mode 100644 index b5c06dd..0000000 --- a/migrations/000004_remove_review_workflow.down.sql +++ /dev/null @@ -1 +0,0 @@ --- The review workflow is intentionally not restored by rollback. diff --git a/migrations/000004_remove_review_workflow.up.sql b/migrations/000004_remove_review_workflow.up.sql deleted file mode 100644 index 7ed908e..0000000 --- a/migrations/000004_remove_review_workflow.up.sql +++ /dev/null @@ -1,15 +0,0 @@ -UPDATE sop_versions -SET status = 'draft', reviewed_by = NULL -WHERE status = 'reviewing'; - -UPDATE sops -SET status = CASE - WHEN EXISTS ( - SELECT 1 - FROM sop_versions - WHERE sop_versions.sop_id = sops.id - AND sop_versions.status = 'published' - ) THEN 'published' - ELSE 'draft' -END -WHERE status = 'reviewing'; diff --git a/migrations/000005_generic_scenario_runtime.down.sql b/migrations/000005_generic_scenario_runtime.down.sql deleted file mode 100644 index 3473210..0000000 --- a/migrations/000005_generic_scenario_runtime.down.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE sop_runs DROP INDEX uk_sop_runs_external_ref; -ALTER TABLE sop_runs DROP COLUMN outputs, DROP COLUMN derived, DROP COLUMN input, DROP COLUMN external_ref; -ALTER TABLE scenario_fields DROP COLUMN source_path; -ALTER TABLE scenarios DROP COLUMN output_schema, DROP COLUMN input_schema; diff --git a/migrations/000005_generic_scenario_runtime.up.sql b/migrations/000005_generic_scenario_runtime.up.sql deleted file mode 100644 index ef349fc..0000000 --- a/migrations/000005_generic_scenario_runtime.up.sql +++ /dev/null @@ -1,20 +0,0 @@ -ALTER TABLE scenarios - ADD COLUMN input_schema JSON NULL AFTER created_by, - ADD COLUMN output_schema JSON NULL AFTER input_schema; - -UPDATE scenarios SET input_schema = JSON_OBJECT('fields', JSON_ARRAY()), output_schema = JSON_OBJECT('fields', JSON_ARRAY()); -ALTER TABLE scenarios MODIFY input_schema JSON NOT NULL, MODIFY output_schema JSON NOT NULL; - -ALTER TABLE scenario_fields - ADD COLUMN source_path VARCHAR(255) NOT NULL DEFAULT '' AFTER field_name; - -ALTER TABLE sop_runs - ADD COLUMN external_ref VARCHAR(191) NULL AFTER operator_id, - ADD COLUMN input JSON NULL AFTER answers, - ADD COLUMN derived JSON NULL AFTER input, - ADD COLUMN outputs JSON NULL AFTER derived; - -UPDATE sop_runs SET input = answers, derived = JSON_OBJECT(), outputs = JSON_ARRAY(); -ALTER TABLE sop_runs MODIFY input JSON NOT NULL, MODIFY derived JSON NOT NULL, MODIFY outputs JSON NOT NULL; - -ALTER TABLE sop_runs ADD UNIQUE KEY uk_sop_runs_external_ref (tenant_id, sop_id, external_ref); diff --git a/migrations/000006_knowledge_graph.down.sql b/migrations/000006_knowledge_graph.down.sql deleted file mode 100644 index 92b6e92..0000000 --- a/migrations/000006_knowledge_graph.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE IF EXISTS knowledge_relations; -DROP TABLE IF EXISTS knowledge_items; diff --git a/migrations/000006_knowledge_graph.up.sql b/migrations/000006_knowledge_graph.up.sql deleted file mode 100644 index 9da33e4..0000000 --- a/migrations/000006_knowledge_graph.up.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE knowledge_items ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - scenario_id BIGINT UNSIGNED NOT NULL, - item_key VARCHAR(64) NOT NULL, - name VARCHAR(128) NOT NULL, - type VARCHAR(64) NOT NULL, - content JSON NOT NULL, - status VARCHAR(24) NOT NULL DEFAULT 'active', - sort_order INT NOT NULL DEFAULT 0, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), - UNIQUE KEY uk_knowledge_items_key (scenario_id, item_key), - KEY idx_knowledge_items_type (tenant_id, scenario_id, type, status), - CONSTRAINT fk_knowledge_items_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_knowledge_items_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE knowledge_relations ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - scenario_id BIGINT UNSIGNED NOT NULL, - from_knowledge_id BIGINT UNSIGNED NOT NULL, - relation_type VARCHAR(64) NOT NULL, - to_knowledge_id BIGINT UNSIGNED NOT NULL, - `condition` JSON NOT NULL, - sort_order INT NOT NULL DEFAULT 0, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), - UNIQUE KEY uk_knowledge_relation (scenario_id, from_knowledge_id, relation_type, to_knowledge_id), - KEY idx_knowledge_relation_from (tenant_id, scenario_id, from_knowledge_id, relation_type), - CONSTRAINT fk_knowledge_relations_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_knowledge_relations_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios(id) ON DELETE CASCADE, - CONSTRAINT fk_knowledge_relations_from FOREIGN KEY (from_knowledge_id) REFERENCES knowledge_items(id) ON DELETE CASCADE, - CONSTRAINT fk_knowledge_relations_to FOREIGN KEY (to_knowledge_id) REFERENCES knowledge_items(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/migrations/000007_public_sdk_access.down.sql b/migrations/000007_public_sdk_access.down.sql deleted file mode 100644 index acdda67..0000000 --- a/migrations/000007_public_sdk_access.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -DROP TABLE IF EXISTS public_run_sessions; -ALTER TABLE scenarios DROP INDEX uk_scenarios_public_key, DROP INDEX uk_scenarios_scenario_key; -ALTER TABLE scenarios DROP COLUMN allowed_origins, DROP COLUMN public_key, DROP COLUMN scenario_key; diff --git a/migrations/000007_public_sdk_access.up.sql b/migrations/000007_public_sdk_access.up.sql deleted file mode 100644 index ab33277..0000000 --- a/migrations/000007_public_sdk_access.up.sql +++ /dev/null @@ -1,31 +0,0 @@ -ALTER TABLE scenarios - ADD COLUMN scenario_key VARCHAR(128) NULL AFTER tenant_id, - ADD COLUMN public_key VARCHAR(128) NULL AFTER scenario_key, - ADD COLUMN allowed_origins JSON NULL AFTER public_key; - -UPDATE scenarios -SET scenario_key = CONCAT('scenario-', id), - public_key = CONCAT('pk_', REPLACE(UUID(), '-', '')), - allowed_origins = JSON_ARRAY(); - -ALTER TABLE scenarios - MODIFY scenario_key VARCHAR(128) NOT NULL, - MODIFY public_key VARCHAR(128) NOT NULL, - MODIFY allowed_origins JSON NOT NULL, - ADD UNIQUE KEY uk_scenarios_scenario_key (scenario_key), - ADD UNIQUE KEY uk_scenarios_public_key (public_key); - -CREATE TABLE public_run_sessions ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - run_id BIGINT UNSIGNED NOT NULL, - token_hash VARCHAR(64) NOT NULL, - expires_at DATETIME(3) NOT NULL, - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), - UNIQUE KEY uk_public_run_sessions_token (token_hash), - KEY idx_public_run_sessions_run (tenant_id, run_id), - CONSTRAINT fk_public_sessions_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_public_sessions_run FOREIGN KEY (run_id) REFERENCES sop_runs(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/migrations/000008_scenario_rules.down.sql b/migrations/000008_scenario_rules.down.sql deleted file mode 100644 index fcc4c51..0000000 --- a/migrations/000008_scenario_rules.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS scenario_rules; diff --git a/migrations/000008_scenario_rules.up.sql b/migrations/000008_scenario_rules.up.sql deleted file mode 100644 index 9a76c36..0000000 --- a/migrations/000008_scenario_rules.up.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE scenario_rules ( - id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - tenant_id BIGINT UNSIGNED NOT NULL, - scenario_id BIGINT UNSIGNED NOT NULL, - rule_key VARCHAR(64) NOT NULL, - name VARCHAR(128) NOT NULL, - `condition` JSON NOT NULL, - actions JSON NOT NULL, - priority INT NOT NULL DEFAULT 0, - status VARCHAR(24) NOT NULL DEFAULT 'active', - created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), - PRIMARY KEY (id), - UNIQUE KEY uk_scenario_rules_key (scenario_id, rule_key), - KEY idx_scenario_rules_active (tenant_id, scenario_id, status, priority), - CONSTRAINT fk_scenario_rules_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id), - CONSTRAINT fk_scenario_rules_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios(id) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/migrations/000009_run_knowledge_snapshot.down.sql b/migrations/000009_run_knowledge_snapshot.down.sql deleted file mode 100644 index 014ec78..0000000 --- a/migrations/000009_run_knowledge_snapshot.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE sop_runs DROP COLUMN knowledge_snapshot; diff --git a/migrations/000009_run_knowledge_snapshot.up.sql b/migrations/000009_run_knowledge_snapshot.up.sql deleted file mode 100644 index a7a4b63..0000000 --- a/migrations/000009_run_knowledge_snapshot.up.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE sop_runs ADD COLUMN knowledge_snapshot JSON NULL AFTER outputs; -UPDATE sop_runs SET knowledge_snapshot = JSON_OBJECT('items', JSON_ARRAY(), 'relations', JSON_ARRAY()); -ALTER TABLE sop_runs MODIFY knowledge_snapshot JSON NOT NULL; diff --git a/migrations/000010_scenario_final_result.down.sql b/migrations/000010_scenario_final_result.down.sql deleted file mode 100644 index a2d5f37..0000000 --- a/migrations/000010_scenario_final_result.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE sop_runs DROP COLUMN final_result; -ALTER TABLE scenarios DROP COLUMN result_schema; diff --git a/migrations/000010_scenario_final_result.up.sql b/migrations/000010_scenario_final_result.up.sql deleted file mode 100644 index 75495c8..0000000 --- a/migrations/000010_scenario_final_result.up.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE scenarios - ADD COLUMN result_schema JSON NULL AFTER output_schema; - -UPDATE scenarios SET result_schema = JSON_OBJECT('fields', JSON_ARRAY()); -ALTER TABLE scenarios MODIFY result_schema JSON NOT NULL; - -ALTER TABLE sop_runs - ADD COLUMN final_result JSON NULL AFTER result;