Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push command incorrectly detects changes #391

Open
GetPsyched opened this issue May 9, 2024 · 0 comments
Open

push command incorrectly detects changes #391

GetPsyched opened this issue May 9, 2024 · 0 comments

Comments

@GetPsyched
Copy link

GetPsyched commented May 9, 2024

Problem

Ever since I've used the push command, I get a LONG list of changes that occur even when nothing has changed at all. Since there were a lot of changes, I didn't know where to begin debugging since it might as well be failing on everything that's like, say, an array type; especially given it seemed like an upstream issue.

But today, after bumping to latest release 0.21.0, the number of those changes dropped down to just 4; they're still meaningless and nothing actually changed, but now I could debug it.

ALTER TABLE "courses" ALTER COLUMN "prerequisites" SET DEFAULT '{}';
ALTER TABLE "courses" ALTER COLUMN "similar_courses" SET DEFAULT '{}';
ALTER TABLE "club_members" ALTER COLUMN "position" SET DEFAULT 'member';
ALTER TABLE "club_members" ALTER COLUMN "internal_groups" SET DEFAULT '{}';

Potential cause

After looking around that what's so special about these columns specifically, I'm drawing the conclusion that it occurs for columns with both a length constraint and a default specifier.

Here are the column definitions:

// courses.schema.ts
export const courses = pgTable('courses', {
  // --- snip ---
  prerequisites: varchar('prerequisites', { length: 7 })
    .array()
    .default(sql`'{}'`)
    .notNull(),
  similarCourses: varchar('similar_courses', { length: 7 })
    .array()
    .default(sql`'{}'`)
    .notNull(),
  // --- snip ---
});

// club-members.schema.ts
export const clubMembers = pgTable('club_members', {
  // --- snip ---
  position: varchar('position', { length: 32 }).default('member').notNull(),
  internalGroups: varchar('internal_groups', { length: 32 })
  // --- snip ---
});

This might be related to #319.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant