[openstreetmap/openstreetmap-website] Align structure.sql with generated output (Issue #4298)
Tom Hughes
notifications at github.com
Wed Oct 18 15:54:53 UTC 2023
I have loads of differences for things like that (which I think is probably down to postgres version) or field ordering (which is mostly down to me having applied and reverted migrations at various times and in various orders) and I generally figure that trying to "fix" them is as likely to break them for other people as it is to fix them for me... My current diff is:
```patch
diff --git a/db/structure.sql b/db/structure.sql
index 939799c0a..78eef205f 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -9,6 +9,13 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
+--
+-- Name: public; Type: SCHEMA; Schema: -; Owner: -
+--
+
+-- *not* creating schema, since initdb creates it
+
+
--
-- Name: btree_gist; Type: EXTENSION; Schema: -; Owner: -
--
@@ -16,6 +23,13 @@ SET row_security = off;
CREATE EXTENSION IF NOT EXISTS btree_gist WITH SCHEMA public;
+--
+-- Name: EXTENSION btree_gist; Type: COMMENT; Schema: -; Owner: -
+--
+
+COMMENT ON EXTENSION btree_gist IS 'support for indexing common datatypes in GiST';
+
+
--
-- Name: format_enum; Type: TYPE; Schema: public; Owner: -
--
@@ -107,6 +121,39 @@ CREATE TYPE public.user_status_enum AS ENUM (
'deleted'
);
+
+--
+-- Name: tile_for_point(integer, integer); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION public.tile_for_point(scaled_lat integer, scaled_lon integer) RETURNS bigint
+ LANGUAGE plpgsql IMMUTABLE
+ AS $$
+DECLARE
+ x int8; -- quantized x from lon,
+ y int8; -- quantized y from lat,
+BEGIN
+ x := round(((scaled_lon / 10000000.0) + 180.0) * 65535.0 / 360.0);
+ y := round(((scaled_lat / 10000000.0) + 90.0) * 65535.0 / 180.0);
+
+ -- these bit-masks are special numbers used in the bit interleaving algorithm.
+ -- see https://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN
+ -- for the original algorithm and more details.
+ x := (x | (x << 8)) & 16711935; -- 0x00FF00FF
+ x := (x | (x << 4)) & 252645135; -- 0x0F0F0F0F
+ x := (x | (x << 2)) & 858993459; -- 0x33333333
+ x := (x | (x << 1)) & 1431655765; -- 0x55555555
+
+ y := (y | (y << 8)) & 16711935; -- 0x00FF00FF
+ y := (y | (y << 4)) & 252645135; -- 0x0F0F0F0F
+ y := (y | (y << 2)) & 858993459; -- 0x33333333
+ y := (y | (y << 1)) & 1431655765; -- 0x55555555
+
+ RETURN (x << 1) | y;
+END;
+$$;
+
+
SET default_tablespace = '';
SET default_table_access_method = heap;
@@ -250,8 +297,8 @@ ALTER SEQUENCE public.active_storage_variant_records_id_seq OWNED BY public.acti
CREATE TABLE public.ar_internal_metadata (
key character varying NOT NULL,
value character varying,
- created_at timestamp(6) without time zone NOT NULL,
- updated_at timestamp(6) without time zone NOT NULL
+ created_at timestamp without time zone NOT NULL,
+ updated_at timestamp without time zone NOT NULL
);
@@ -274,7 +321,6 @@ CREATE TABLE public.changeset_comments (
--
CREATE SEQUENCE public.changeset_comments_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -376,7 +422,6 @@ CREATE TABLE public.client_applications (
--
CREATE SEQUENCE public.client_applications_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -802,7 +847,6 @@ CREATE TABLE public.issue_comments (
--
CREATE SEQUENCE public.issue_comments_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -842,7 +886,6 @@ CREATE TABLE public.issues (
--
CREATE SEQUENCE public.issues_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -955,7 +998,6 @@ CREATE TABLE public.note_comments (
--
CREATE SEQUENCE public.note_comments_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -991,7 +1033,6 @@ CREATE TABLE public.notes (
--
CREATE SEQUENCE public.notes_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1137,7 +1178,6 @@ CREATE TABLE public.oauth_nonces (
--
CREATE SEQUENCE public.oauth_nonces_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1216,7 +1256,6 @@ CREATE TABLE public.oauth_tokens (
--
CREATE SEQUENCE public.oauth_tokens_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1251,7 +1290,6 @@ CREATE TABLE public.redactions (
--
CREATE SEQUENCE public.redactions_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1326,7 +1364,6 @@ CREATE TABLE public.reports (
--
CREATE SEQUENCE public.reports_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1373,7 +1410,6 @@ CREATE TABLE public.user_blocks (
--
CREATE SEQUENCE public.user_blocks_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1406,9 +1442,9 @@ CREATE TABLE public.user_preferences (
CREATE TABLE public.user_roles (
id integer NOT NULL,
user_id bigint NOT NULL,
- role public.user_role_enum NOT NULL,
created_at timestamp without time zone,
updated_at timestamp without time zone,
+ role public.user_role_enum NOT NULL,
granter_id bigint NOT NULL
);
@@ -1418,7 +1454,6 @@ CREATE TABLE public.user_roles (
--
CREATE SEQUENCE public.user_roles_id_seq
- AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -3512,3 +3547,5 @@ INSERT INTO "schema_migrations" (version) VALUES
('7'),
('8'),
('9');
+
+
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/4298#issuecomment-1768784767
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/issues/4298/1768784767 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20231018/241f2f90/attachment.htm>
More information about the rails-dev
mailing list