Files
accounted/supabase/migrations/20260408130000_sie_files_storage_bucket.sql
T
Mattsson bf5a8d9195 Fix/multiple company (#203)
* Refactor onboarding and dashboard logic; add silent team creation for users

- Removed unnecessary useCompany context in DashboardContent and SettingsSidebar components.
- Simplified onboarding setup logic to allow direct access to the dashboard for users without companies.
- Introduced WelcomeOnboarding component to handle user onboarding steps.
- Added migration to create silent teams for all users at signup, backfilling existing users without teams, and cleaning up incomplete companies.

* fix: update greeting logic and improve email handling in TIC extension

* Redirect to onboarding for users without companies and update onboarding flow

* Build issue fix

* Enhance onboarding experience by adding existing companies check
2026-04-09 11:54:12 +02:00

50 lines
1.9 KiB
SQL

-- Migration: Create 'sie-files' storage bucket for SIE file archival
-- The SIE import flow archives imported files to Supabase Storage for
-- BFL 7 kap 1-2§ retention compliance, but the bucket was never created.
-- Path convention: {company_id}/{import_id}.se
-- =============================================================================
-- 1. Create the 'sie-files' bucket (private, 10MB limit, text only)
-- =============================================================================
INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
VALUES (
'sie-files',
'sie-files',
false,
52428800, -- 50 MB, matches MAX_FILE_SIZE in the parse route
ARRAY['text/plain']
)
ON CONFLICT (id) DO NOTHING;
-- =============================================================================
-- 2. INSERT policy: Users can upload to companies they belong to
-- =============================================================================
CREATE POLICY "sie_files_insert"
ON storage.objects
FOR INSERT
TO authenticated
WITH CHECK (
bucket_id = 'sie-files'
AND (storage.foldername(name))[1]::uuid IN (SELECT public.user_company_ids())
);
-- =============================================================================
-- 3. SELECT policy: Users can read files from companies they belong to
-- =============================================================================
CREATE POLICY "sie_files_select"
ON storage.objects
FOR SELECT
TO authenticated
USING (
bucket_id = 'sie-files'
AND (storage.foldername(name))[1]::uuid IN (SELECT public.user_company_ids())
);
-- =============================================================================
-- No UPDATE or DELETE policies — WORM compliance for BFL retention
-- Service role bypasses RLS for admin/cron access
-- =============================================================================