Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions admin/src/apis/flyway/flyway.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { fetcher } from '@bombom/shared/apis';

export type MigrationStatus =
| 'LOCAL_WIP'
| 'PR_REVIEW'
| 'MERGE_PENDING'
| 'DB_APPLIED';

export type WorkKind = 'NEW_TABLE' | 'EXISTING_TABLE';

export type ConflictSeverity = 'TABLE' | 'COLUMN';

export type MigrationItem = {
version: string;
description: string;
fileName: string;
status: MigrationStatus;
createsNewTable: boolean;
tables: string[];
sourceLabel: string;
sourceUrl: string;
author: string;
};

export type FlywayConflict = {
version: string;
sources: string[];
suggestedVersion: string;
};

export type FlywayLeapfrog = {
mineVersion: string;
aheadVersion: string;
sharedTables: string[];
severity: ConflictSeverity;
};

export type FlywayOverview = {
deployBranch: string;
integrationBranch: string;
latestVersion: string;
appliedCount: number;
pendingCount: number;
nextSafeMinor: string;
nextSafeMajor: string;
migrations: MigrationItem[];
conflicts: FlywayConflict[];
leapfrogWarnings: FlywayLeapfrog[];
};

export type MigrationScript = {
fileName: string;
content: string;
sourceUrl: string;
};

export type CreateWipIssuePayload = {
workKind: WorkKind;
targetTable?: string;
plannedVersion: string;
description: string;
assignee: string;
};

export type CreateWipIssueResponse = {
issueNumber: number;
issueUrl: string;
};

export const getFlywayOverview = async () => {
return fetcher.get<FlywayOverview>({
path: '/flyway/overview',
});
};

export const getMigrationScript = async (fileName: string) => {
return fetcher.get<MigrationScript>({
path: '/flyway/script',
query: { fileName },
});
};

export const createWipIssue = async (payload: CreateWipIssuePayload) => {
return fetcher.post<CreateWipIssuePayload, CreateWipIssueResponse>({
path: '/flyway/wip',
body: payload,
});
};
34 changes: 34 additions & 0 deletions admin/src/apis/flyway/flyway.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { queryOptions } from '@tanstack/react-query';
import {
getFlywayOverview,
getMigrationScript,
createWipIssue,
} from './flyway.api';

const OVERVIEW_STALE_TIME = 1000 * 30; // 30s
const SCRIPT_STALE_TIME = 1000 * 60 * 10; // 10m

export const flywayQueries = {
all: ['flyway'] as const,

overview: () =>
queryOptions({
queryKey: ['flyway', 'overview'] as const,
queryFn: getFlywayOverview,
staleTime: OVERVIEW_STALE_TIME,
}),

script: (fileName: string) =>
queryOptions({
queryKey: ['flyway', 'script', fileName] as const,
queryFn: () => getMigrationScript(fileName),
staleTime: SCRIPT_STALE_TIME,
enabled: fileName.length > 0,
}),

mutation: {
createWip: () => ({
mutationFn: createWipIssue,
}),
},
};
5 changes: 5 additions & 0 deletions admin/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
FiBell,
FiCalendar,
FiCode,
FiDatabase,
FiEdit,
FiFlag,
FiHome,
Expand Down Expand Up @@ -40,6 +41,10 @@ export const Sidebar = () => {
<FiBell />
<span>공지사항</span>
</NavItem>
<NavItem to="/flyway" $isActive={currentPath.startsWith('/flyway')}>
<FiDatabase />
<span>Flyway 형상</span>
</NavItem>
<NavItem
to="/newsletters"
$isActive={currentPath.startsWith('/newsletters')}
Expand Down
Loading
Loading