feat(db): add automatic Drizzle migration on app startup

This commit is contained in:
2026-08-07 12:58:47 +02:00
parent 11f0d16515
commit 16a8970d29
6 changed files with 92 additions and 17 deletions
+57 -7
View File
@@ -1,12 +1,62 @@
// This file is required for Expo/React Native SQLite migrations - https://orm.drizzle.team/quick-sqlite/expo
import journal from './meta/_journal.json';
import m0000 from './0000_mushy_groot.sql';
export default {
journal,
migrations: {
m0000
}
const m0000 = `
CREATE TABLE \`laps\` (
\`id\` text PRIMARY KEY NOT NULL,
\`workout_id\` text NOT NULL,
\`set_position\` integer NOT NULL,
\`rep_number\` integer NOT NULL,
\`distance\` integer NOT NULL,
\`duration\` real NOT NULL,
\`stroke_count\` integer,
\`heart_rate\` integer,
\`swolf\` real,
FOREIGN KEY (\`workout_id\`) REFERENCES \`workouts\`(\`id\`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE \`sets\` (
\`id\` text PRIMARY KEY NOT NULL,
\`workout_id\` text NOT NULL,
\`position\` integer NOT NULL,
\`stroke\` text NOT NULL,
\`distance_per_rep\` integer NOT NULL,
\`rep_count\` integer NOT NULL,
\`rest_type\` text DEFAULT 'fixed_rest' NOT NULL,
\`rest_duration\` real DEFAULT 0 NOT NULL,
\`target_time\` real,
FOREIGN KEY (\`workout_id\`) REFERENCES \`workouts\`(\`id\`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE \`templates\` (
\`id\` text PRIMARY KEY NOT NULL,
\`name\` text NOT NULL,
\`description\` text,
\`pool_length\` real DEFAULT 25 NOT NULL,
\`json_data\` text NOT NULL,
\`is_favorite\` integer DEFAULT false NOT NULL,
\`created_at\` text NOT NULL
);
--> statement-breakpoint
CREATE TABLE \`workouts\` (
\`id\` text PRIMARY KEY NOT NULL,
\`name\` text,
\`template_id\` text,
\`pool_length\` real DEFAULT 25 NOT NULL,
\`started_at\` text NOT NULL,
\`finished_at\` text,
\`total_distance\` integer,
\`total_duration\` real,
\`calories\` real,
\`avg_heart_rate\` integer,
\`source\` text DEFAULT 'manual' NOT NULL
);
`;
export default {
journal,
migrations: {
m0000
}
}