Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Database Migrations for Antigravity

Database Migrations for Antigravity

Master database schema migrations with Prisma and Drizzle ORM including rollbacks, seeding, and production deployment strategies.

DatabasePrismaDrizzlePostgreSQLTypeScript
by Antigravity Team
⭐0Stars
.antigravity
# Database Migrations for Google Antigravity

Proper database migration management is essential for maintaining data integrity across environments. This guide covers migration strategies optimized for Google Antigravity development workflows.

## Prisma Migration Setup

Configure Prisma for robust migration management:

```typescript
// prisma/schema.prisma
generator client {
  provider = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}

model User {
  id            String    @id @default(cuid())
  email         String    @unique
  name          String?
  emailVerified DateTime?
  image         String?
  role          Role      @default(USER)
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
  posts         Post[]
  accounts      Account[]
  sessions      Session[]

  @@index([email])
  @@map("users")
}

model Post {
  id          String   @id @default(cuid())
  title       String   @db.VarChar(255)
  slug        String   @unique
  content     String   @db.Text
  published   Boolean  @default(false)
  authorId    String
  author      User     @relation(fields: [authorId], references: [id], onDelete: Cascade)
  categories  Category[]
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt

  @@index([authorId])
  @@index([slug])
  @@map("posts")
}

enum Role {
  USER
  ADMIN
  MODERATOR
}
```

## Migration Commands and Scripts

Create migration management scripts:

```typescript
// scripts/migrate.ts
import { execSync } from "child_process";

type MigrationAction = "create" | "deploy" | "reset" | "status";

async function runMigration(action: MigrationAction, name?: string) {
  const commands: Record<MigrationAction, string> = {
    create: `prisma migrate dev --name ${name || "migration"}`,
    deploy: "prisma migrate deploy",
    reset: "prisma migrate reset --force",
    status: "prisma migrate status",
  };

  console.log(`Running migration: ${action}`);
  
  try {
    execSync(commands[action], { stdio: "inherit" });
    console.log(`Migration ${action} completed successfully`);
  } catch (error) {
    console.error(`Migration ${action} failed:`, error);
    process.exit(1);
  }
}

// Run from command line
const action = process.argv[2] as MigrationAction;
const name = process.argv[3];
runMigration(action, name);
```

## Drizzle Migration Alternative

For Drizzle ORM users:

```typescript
// drizzle/schema.ts
import { pgTable, text, timestamp, boolean, varchar, pgEnum } from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";

export const roleEnum = pgEnum("role", ["user", "admin", "moderator"]);

export const users = pgTable("users", {
  id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
  email: text("email").unique().notNull(),
  name: text("name"),
  emailVerified: timestamp("email_verified"),
  image: text("image"),
  role: roleEnum("role").default("user"),
  createdAt: timestamp("created_at").defaultNow(),
  updatedAt: timestamp("updated_at").defaultNow(),
});

export const posts = pgTable("posts", {
  id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
  title: varchar("title", { length: 255 }).notNull(),
  slug: text("slug").unique().notNull(),
  content: text("content"),
  published: boolean("published").default(false),
  authorId: text("author_id").references(() => users.id, { onDelete: "cascade" }),
  createdAt: timestamp("created_at").defaultNow(),
  updatedAt: timestamp("updated_at").defaultNow(),
});

export const usersRelations = relations(users, ({ many }) => ({
  posts: many(posts),
}));

export const postsRelations = relations(posts, ({ one }) => ({
  author: one(users, {
    fields: [posts.authorId],
    references: [users.id],
  }),
}));

// drizzle/migrate.ts
import { drizzle } from "drizzle-orm/node-postgres";
import { migrate } from "drizzle-orm/node-postgres/migrator";
import { Pool } from "pg";

async function runMigrations() {
  const pool = new Pool({
    connectionString: process.env.DATABASE_URL,
  });

  const db = drizzle(pool);

  console.log("Running migrations...");
  await migrate(db, { migrationsFolder: "./drizzle/migrations" });
  console.log("Migrations completed");

  await pool.end();
}

runMigrations().catch(console.error);
```

## Database Seeding

Create comprehensive seed scripts:

```typescript
// prisma/seed.ts
import { PrismaClient, Role } from "@prisma/client";
import { hash } from "bcryptjs";

const prisma = new PrismaClient();

async function main() {
  console.log("Starting seed...");

  // Create admin user
  const adminPassword = await hash("admin123", 12);
  const admin = await prisma.user.upsert({
    where: { email: "admin@example.com" },
    update: {},
    create: {
      email: "admin@example.com",
      name: "Admin User",
      role: Role.ADMIN,
    },
  });

  // Create sample posts
  const posts = await Promise.all(
    Array.from({ length: 10 }, (_, i) =>
      prisma.post.upsert({
        where: { slug: `sample-post-${i + 1}` },
        update: {},
        create: {
          title: `Sample Post ${i + 1}`,
          slug: `sample-post-${i + 1}`,
          content: `Content for sample post ${i + 1}`,
          published: i < 5,
          authorId: admin.id,
        },
      })
    )
  );

  console.log(`Created ${posts.length} posts`);
}

main()
  .catch(console.error)
  .finally(() => prisma.$disconnect());
```

## Best Practices

When managing migrations in Antigravity projects, always review generated SQL before applying, use transactions for complex migrations, create backup scripts for production, test migrations in staging first, version control all migration files, document breaking changes, and implement rollback procedures for critical migrations.

When to Use This Prompt

This Database prompt is ideal for developers working on:

  • Database applications requiring modern best practices and optimal performance
  • Projects that need production-ready Database code with proper error handling
  • Teams looking to standardize their database development workflow
  • Developers wanting to learn industry-standard Database patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their database implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the Database code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this Database prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For Database projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...