1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【React】位置情報がテーブルに保存されない症状の解決方法

Posted at

はじめに

取得した位置情報をsupabaseのテーブルへ保存しようとした際、以下のようなエラーが表示されました。
こちらの解決方法について躓いたため備忘録をふくm記事にします。

アクセス権限がないようです。
既に以下のようにgisスキーマを作成しPostGIS拡張機能を許可していましたが、うまく挙動していないようでした。

CREATE SCHEMA gis;
create extension postgis with schema gis;

解決方法

作成したgisスキーマを削除し、extensionsスキーマにPostGIS拡張機能を許可

強制削除

DROP EXTENSION postgis CASCADE;

extensionsスキーマにPostGIS拡張機能を許可

CREATE EXTENSION postgis WITH SCHEMA extensions;

権限付与

GRANT USAGE ON SCHEMA extensions TO anon, authenticated, service_role;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA extensions TO anon, authenticated, service_role;

テーブル再作成

create table if not exists public.post_locations (
post_id int not null references posts(id) on delete cascade,
location geography(POINT) not null,
PRIMARY KEY(post_id)
);

Database反映

npx supabase gen types typescript --project-id "プロジェクトID" --schema public > utils/supabase-database.ts

参考

おわりに

とりあえず今回はこちらの方法で解決することができました。
データベースの扱いももっと習熟したいと思いました。


1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?