mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 03:11:32 +00:00
make random_smallint function work in postgresql 16
This commit is contained in:
parent
fbbf088932
commit
cd1b202612
1 changed files with 4 additions and 2 deletions
|
@ -5,8 +5,10 @@
|
||||||
CREATE FUNCTION random_smallint ()
|
CREATE FUNCTION random_smallint ()
|
||||||
RETURNS smallint
|
RETURNS smallint
|
||||||
LANGUAGE sql
|
LANGUAGE sql
|
||||||
VOLATILE PARALLEL RESTRICTED RETURN random (
|
VOLATILE PARALLEL RESTRICTED RETURN
|
||||||
-32768, 32767
|
-- https://stackoverflow.com/questions/1400505/generate-a-random-number-in-the-range-1-10/1400752#1400752
|
||||||
|
-- (`+ 1` makes the upper bound inclusive)
|
||||||
|
trunc ((random() * (32768 + 32767 + 1)) - 32768
|
||||||
);
|
);
|
||||||
|
|
||||||
ALTER TABLE community
|
ALTER TABLE community
|
||||||
|
|
Loading…
Reference in a new issue