Skip to content

feat: implement database schema for merge freeze windows (#819) - #824

Open
desireddymohithreddy0925 wants to merge 2 commits into
Coder-s-OG-s:mainfrom
desireddymohithreddy0925:feature/merge-freeze-windows
Open

feat: implement database schema for merge freeze windows (#819)#824
desireddymohithreddy0925 wants to merge 2 commits into
Coder-s-OG-s:mainfrom
desireddymohithreddy0925:feature/merge-freeze-windows

Conversation

@desireddymohithreddy0925

@desireddymohithreddy0925 desireddymohithreddy0925 commented Jul 28, 2026

Copy link
Copy Markdown

Closes #819

Description

This PR implements the database schema required for the Configurable Merge Freeze Windows feature.

Changes Made

  • Added merge_freeze_windows table to src/lib/db/schema.ts
  • Linked freeze windows to githubInstallations for repository-level configuration
  • Added fields for cronSchedule, isEmergencyFreeze, and custom freezeMessage

Next Steps

This serves as the foundational data layer. Subsequent PRs will implement the UI settings panel and the backend middleware to block the merge API requests.

Screenshots / UI Thoughts

No UI changes in this PR as this is the backend schema foundation.

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel.

A member of the Team first needs to authorize it.

@jakharmonika364 jakharmonika364 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New file supabase/migrations/0044_merge_freeze_windows.sql (next number after 0043_activity_log_read_at.sql) - creates the table and locks it down like installation_settings:

create table merge_freeze_windows (
  id uuid primary key default gen_random_uuid(),
  installation_id bigint not null references github_installations(id) on delete cascade,
  cron_schedule text,
  is_emergency_freeze boolean not null default false,
  freeze_message text,
  created_at timestamptz not null default now(),
  updated_at timestamptz not null default now()
);

create index merge_freeze_windows_installation_idx on merge_freeze_windows(installation_id);

alter table merge_freeze_windows enable row level security;

create policy merge_freeze_windows_admin_rw on merge_freeze_windows
  for all
  using (
    exists (
      select 1 from github_installation_users giu
      where giu.installation_id = merge_freeze_windows.installation_id
        and giu.user_id = auth.uid()
        and giu.permission_level in ('org_admin', 'repo_admin')
    )
  )
  with check (
    exists (
      select 1 from github_installation_users giu
      where giu.installation_id = merge_freeze_windows.installation_id
        and giu.user_id = auth.uid()
        and giu.permission_level in ('org_admin', 'repo_admin')
    )
  );

Comment thread src/lib/db/schema.ts
Comment on lines +755 to +765
export const mergeFreezeWindows = pgTable('merge_freeze_windows', {
id: uuid('id').primaryKey().defaultRandom(),
installationId: bigint('installation_id', { mode: 'number' })
.notNull()
.references(() => githubInstallations.id, { onDelete: 'cascade' }),
cronSchedule: text('cron_schedule'),
isEmergencyFreeze: boolean('is_emergency_freeze').notNull().default(false),
freezeMessage: text('freeze_message'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the table to the 3-arg form and add an installation index (matches orgCommunities/flaggedAccounts pattern):

Suggested change
export const mergeFreezeWindows = pgTable('merge_freeze_windows', {
id: uuid('id').primaryKey().defaultRandom(),
installationId: bigint('installation_id', { mode: 'number' })
.notNull()
.references(() => githubInstallations.id, { onDelete: 'cascade' }),
cronSchedule: text('cron_schedule'),
isEmergencyFreeze: boolean('is_emergency_freeze').notNull().default(false),
freezeMessage: text('freeze_message'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
});
export const mergeFreezeWindows = pgTable(
'merge_freeze_windows',
{
id: uuid('id').primaryKey().defaultRandom(),
installationId: bigint('installation_id', { mode: 'number' })
.notNull()
.references(() => githubInstallations.id, { onDelete: 'cascade' }),
cronSchedule: text('cron_schedule'),
isEmergencyFreeze: boolean('is_emergency_freeze').notNull().default(false),
freezeMessage: text('freeze_message'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
},
(t) => ({
installationIdx: index('merge_freeze_windows_installation_idx').on(t.installationId),
}),
);

@jakharmonika364 jakharmonika364 added the Needs author reply Author need to reply label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs author reply Author need to reply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] - Configurable Merge Freeze Windows

2 participants