From 1cb362e53a023bbb314e87985b551507b88668e4 Mon Sep 17 00:00:00 2001 From: Vilsol Date: Wed, 2 Oct 2024 22:14:16 +0300 Subject: [PATCH] chore: state fix --- db/schema/version.go | 2 +- go.mod | 4 +++- migrations/sql/20241002191358_state_fix.down.sql | 16 ++++++++++++++++ migrations/sql/20241002191358_state_fix.up.sql | 2 ++ migrations/sql/atlas.sum | 4 +++- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 migrations/sql/20241002191358_state_fix.down.sql create mode 100644 migrations/sql/20241002191358_state_fix.up.sql diff --git a/db/schema/version.go b/db/schema/version.go index 2c21f53..d2e2e24 100644 --- a/db/schema/version.go +++ b/db/schema/version.go @@ -26,7 +26,7 @@ func (Version) Fields() []ent.Field { field.String("mod_id"), field.String("version").MaxLen(16), field.String("game_version"), - field.Bool("required_on_remote"), + field.Bool("required_on_remote").Default(true), field.String("changelog").Optional(), field.Uint("downloads").Default(0), field.String("key").Optional(), diff --git a/go.mod b/go.mod index efaa1c2..3ece5b1 100755 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/satisfactorymodding/smr-api -go 1.22.3 +go 1.22.5 + +toolchain go1.23.0 require ( ariga.io/entcache v0.1.0 diff --git a/migrations/sql/20241002191358_state_fix.down.sql b/migrations/sql/20241002191358_state_fix.down.sql new file mode 100644 index 0000000..557e293 --- /dev/null +++ b/migrations/sql/20241002191358_state_fix.down.sql @@ -0,0 +1,16 @@ +-- reverse: drop "generate_random_id" function +CREATE FUNCTION "generate_random_id" ("length" integer) RETURNS text LANGUAGE plpgsql AS $$ +declare + chars text[] := '{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}'; + result text := ''; + i integer := 0; +begin + if length < 0 then + raise exception 'Given length cannot be less than 0'; + end if; + for i in 1..length loop + result := result || chars[1+random()*(array_length(chars, 1)-1)]; + end loop; + return result; +end; +$$; diff --git a/migrations/sql/20241002191358_state_fix.up.sql b/migrations/sql/20241002191358_state_fix.up.sql new file mode 100644 index 0000000..0f88040 --- /dev/null +++ b/migrations/sql/20241002191358_state_fix.up.sql @@ -0,0 +1,2 @@ +-- drop "generate_random_id" function +DROP FUNCTION "generate_random_id"; diff --git a/migrations/sql/atlas.sum b/migrations/sql/atlas.sum index d126c66..7c4afaf 100644 --- a/migrations/sql/atlas.sum +++ b/migrations/sql/atlas.sum @@ -1,4 +1,4 @@ -h1:y/Q8pNjcrL7pi8F3JUxIBsFUtvbWFdFKmH3sqWVr3zs= +h1:67tUWb0QFZPzh+o8osVd09uCPAo5q/JBGeWwsNVV+PQ= 000001_create_initial_tables.down.sql h1:QcXXwE8ir3PM3vZjQfBihY55WiuLYjN8pbbk/L6U+bs= 000001_create_initial_tables.up.sql h1:EfAqETefs7TW9BDVS4ukiB7wUFs+HQzVdc3qHhdAFd4= 000002_create_user_group_table.down.sql h1:uJjRbQ3H7yvPGNXLD5iSPmderEoWhCNGdsqN8yqBIRY= @@ -73,3 +73,5 @@ h1:y/Q8pNjcrL7pi8F3JUxIBsFUtvbWFdFKmH3sqWVr3zs= 20240826153722_add_thumbhash.up.sql h1:7a9d40zpOnKMamxW14ql3WFXiwXD4O6AjwMlAOVE7ik= 20240930114249_add_required_on_remote.down.sql h1:cbW5+35gg4R78zsjcqPO94e8X1QcYB9nPllGgtKGOr8= 20240930114249_add_required_on_remote.up.sql h1:NZJmXjtKEIHRhVlSSu9nKADo/8xhZAeckrf6NoZMmjk= +20241002191358_state_fix.down.sql h1:EnNOr58ajtIPS7BIgA6l60Jr8hE0ufCE6t0zFdvfnaw= +20241002191358_state_fix.up.sql h1:4bVw9fxEP9MrHBSYuRF3vFCgaWF79EUeacD3e+vSQR4=