ar7casper
ar7casper
Explore posts from servers
DTDrizzle Team
Created by ar7casper on 5/29/2024 in #help
Migration and existing policy issues
When I run migrations, it fails to execute cause it says " applying migrations...PostgresError: policy 'foo' for table 'bar' already exists". First migration was fine, but now, every time I try to add a new migration file it fails on that. Ideas on how to go around it? I'm using postgres on supabase with RLS.
6 replies
DTDrizzle Team
Created by ar7casper on 2/27/2024 in #help
How to set up auth and user management with supabase
I'm using supabase auth, and I want to have a dedicated table for user data that's not auth related. auth.users is being created and managed by Supabase. In their docs (https://supabase.com/docs/guides/auth/managing-user-data#creating-user-tables), they show -
create table public.profiles (
id uuid not null references auth.users on delete cascade,
first_name text,
last_name text,

primary key (id)
);

alter table public.profiles enable row level security;
create table public.profiles (
id uuid not null references auth.users on delete cascade,
first_name text,
last_name text,

primary key (id)
);

alter table public.profiles enable row level security;
And I've been trying to setup my schema to imitate that -
export const roleEnum = pgEnum('role', ['admin', 'viewer', 'editor']);

export const user = pgTable('user', {
id: uuid('id')
.notNull()
.references(() => auth.users.id, { onDelete: 'cascade' })
.primaryKey(),
firstName: varchar('first_name', { length: 256 }).notNull(),
lastName: varchar('last_name', { length: 256 }).notNull(),
email: varchar('email', { length: 256 }).notNull().unique(),
phone: varchar('phone', { length: 256 }),
createdAt: timestamp('created_at', { withTimezone: true })
.notNull()
.default(sql`now()`),
updatedAt: timestamp('updated_at', { withTimezone: true })
.notNull()
.default(sql`now()`),
role: roleEnum('role').notNull().default('viewer'),
});
export const roleEnum = pgEnum('role', ['admin', 'viewer', 'editor']);

export const user = pgTable('user', {
id: uuid('id')
.notNull()
.references(() => auth.users.id, { onDelete: 'cascade' })
.primaryKey(),
firstName: varchar('first_name', { length: 256 }).notNull(),
lastName: varchar('last_name', { length: 256 }).notNull(),
email: varchar('email', { length: 256 }).notNull().unique(),
phone: varchar('phone', { length: 256 }),
createdAt: timestamp('created_at', { withTimezone: true })
.notNull()
.default(sql`now()`),
updatedAt: timestamp('updated_at', { withTimezone: true })
.notNull()
.default(sql`now()`),
role: roleEnum('role').notNull().default('viewer'),
});
Thing is, that under references I have no way to actually access auth schema cause it's done by supabase. I can't seem to find a solution.
3 replies
DTDrizzle Team
Created by ar7casper on 1/7/2024 in #help
set up unit testing
Hi, I've been looking for a guide on how to setup unit testing with drizzle (bun & sqlite if matters), couldn't find anything, would love a nudge in the right direction. Thanks
2 replies
DTDrizzle Team
Created by ar7casper on 11/18/2023 in #help
schema unique case insensitive
Suppose I have a table Clients and I want the name to be unique. But, I want it to be case insensivive, normally I would use COLLATE NOCASE, but I couldn't find how to do that in drizzle. Would love some help please. Using sqlite.
13 replies
PD🧩 Plasmo Developers
Created by ar7casper on 6/12/2023 in #🔰newbie
Google Analytics on Content Script
Hey all, in your docs you talk about how it's possble to use GA in your system, but the example only shows for popup, how about content scripts? are they supported?
7 replies
PD🧩 Plasmo Developers
Created by ar7casper on 3/27/2023 in #🔰newbie
window undefined on background script when trying to login via firebase
I'm using React + Firebase. I have a hook that handles user details and a background script that handles the auth via chrome.identity.getAuthToken after I approve the consent screen, the background script throws "window is not defined" any ideas? I followed this link - https://www.plasmo.com/blog/posts/firebase-chrome-extension
14 replies