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
Drizzle ORM Migration Patterns

Drizzle ORM Migration Patterns

Master Drizzle ORM migrations and schema management for Google Antigravity IDE

Drizzle ORMDatabaseMigrationsTypeScript
by Antigravity AI
⭐0Stars
.antigravity
# Drizzle ORM Migration Patterns for Google Antigravity IDE

Manage database schemas with Drizzle ORM's type-safe migrations using Google Antigravity IDE. This comprehensive guide covers schema design, migration strategies, seeding, and multi-database support for production applications.

## Schema Definition

```typescript
// src/db/schema/users.ts
import { 
  pgTable, 
  text, 
  timestamp, 
  uuid, 
  varchar,
  boolean,
  integer,
  pgEnum,
  index,
  uniqueIndex,
} from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";

// Enums for type safety
export const userRoleEnum = pgEnum("user_role", ["admin", "user", "guest"]);
export const subscriptionStatusEnum = pgEnum("subscription_status", [
  "active", "canceled", "past_due", "trialing"
]);

// Users table
export const users = pgTable("users", {
  id: uuid("id").primaryKey().defaultRandom(),
  email: varchar("email", { length: 255 }).notNull(),
  name: varchar("name", { length: 100 }).notNull(),
  passwordHash: text("password_hash"),
  role: userRoleEnum("role").default("user").notNull(),
  emailVerified: boolean("email_verified").default(false).notNull(),
  avatarUrl: text("avatar_url"),
  stripeCustomerId: varchar("stripe_customer_id", { length: 255 }),
  createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
  updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
}, (table) => ({
  emailIdx: uniqueIndex("users_email_idx").on(table.email),
  stripeIdx: index("users_stripe_idx").on(table.stripeCustomerId),
  roleIdx: index("users_role_idx").on(table.role),
}));

// Subscriptions table
export const subscriptions = pgTable("subscriptions", {
  id: uuid("id").primaryKey().defaultRandom(),
  userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
  stripeSubscriptionId: varchar("stripe_subscription_id", { length: 255 }).notNull(),
  stripePriceId: varchar("stripe_price_id", { length: 255 }).notNull(),
  status: subscriptionStatusEnum("status").notNull(),
  currentPeriodStart: timestamp("current_period_start", { withTimezone: true }).notNull(),
  currentPeriodEnd: timestamp("current_period_end", { withTimezone: true }).notNull(),
  cancelAtPeriodEnd: boolean("cancel_at_period_end").default(false).notNull(),
  createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
}, (table) => ({
  userIdx: index("subscriptions_user_idx").on(table.userId),
  stripeSubIdx: uniqueIndex("subscriptions_stripe_idx").on(table.stripeSubscriptionId),
}));

// Define relations
export const usersRelations = relations(users, ({ many, one }) => ({
  subscriptions: many(subscriptions),
  posts: many(posts),
  profile: one(profiles),
}));

export const subscriptionsRelations = relations(subscriptions, ({ one }) => ({
  user: one(users, {
    fields: [subscriptions.userId],
    references: [users.id],
  }),
}));
```

## Migration Configuration

```typescript
// drizzle.config.ts
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";

dotenv.config({ path: ".env.local" });

export default {
  schema: "./src/db/schema/*",
  out: "./drizzle/migrations",
  dialect: "postgresql",
  dbCredentials: {
    url: process.env.DATABASE_URL!,
  },
  verbose: true,
  strict: true,
  // Migration table configuration
  migrations: {
    table: "__drizzle_migrations",
    schema: "public",
  },
} satisfies Config;
```

## Migration Commands and Seeding

```typescript
// scripts/seed.ts
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
import * as schema from "../src/db/schema";
import { users, posts, categories } from "../src/db/schema";

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

const db = drizzle(pool, { schema });

async function seed() {
  console.log("Seeding database...");

  // Clear existing data in correct order
  await db.delete(posts);
  await db.delete(users);
  await db.delete(categories);

  // Insert categories
  const [tech, lifestyle] = await db.insert(categories).values([
    { name: "Technology", slug: "technology" },
    { name: "Lifestyle", slug: "lifestyle" },
  ]).returning();

  // Insert users
  const [admin, user] = await db.insert(users).values([
    {
      email: "admin@example.com",
      name: "Admin User",
      role: "admin",
      emailVerified: true,
    },
    {
      email: "user@example.com",
      name: "Regular User",
      role: "user",
      emailVerified: true,
    },
  ]).returning();

  // Insert posts with relations
  await db.insert(posts).values([
    {
      title: "Getting Started with Drizzle",
      slug: "getting-started-drizzle",
      content: "Drizzle ORM is a TypeScript ORM...",
      authorId: admin.id,
      categoryId: tech.id,
      published: true,
    },
  ]);

  console.log("Seeding complete!");
}

seed()
  .catch(console.error)
  .finally(() => pool.end());
```

## Best Practices for Google Antigravity IDE

When using Drizzle with Google Antigravity, define schemas in separate files by domain. Use enums for type-safe status fields. Add appropriate indexes for query performance. Implement soft deletes with deletedAt columns. Use transactions for multi-table operations. Let Gemini 3 generate migrations from schema changes automatically.

Google Antigravity's agent mode can analyze your queries and suggest optimal indexes for your schema.

When to Use This Prompt

This Drizzle ORM prompt is ideal for developers working on:

  • Drizzle ORM applications requiring modern best practices and optimal performance
  • Projects that need production-ready Drizzle ORM code with proper error handling
  • Teams looking to standardize their drizzle orm development workflow
  • Developers wanting to learn industry-standard Drizzle ORM 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 drizzle orm 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 Drizzle ORM 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 Drizzle ORM 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 Drizzle ORM projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...