dhakan
dhakan
DTDrizzle Team
Created by dhakan on 7/24/2024 in #help
Multi-step migration in SQLite with 'MODIFY'
I'm trying to create a multi-step migration in SQLite. First an alter to add the field (nullable), then a CONCAT to amend the field, lastly alter to make it non-nullable. I'm getting The supplied SQL string contains more than one statement. Not sure if I'm thinking about this the wrong way... Trying to split up the migrations into three step, but it seems like the last step (ALTER TABLE table MODIFY) to apply the not null constraint is not permitted in sqlite... I'm not sure how to handle this. Any ideas?
41 replies
DTDrizzle Team
Created by dhakan on 7/24/2024 in #help
SQLite 'WHERE table.relationship (one to many) > 0'
Hi! I'm trying to figure out how to query for rows that have a relationship at least defined once.
const allVideos = await db.query.videos.findMany({
where: // Not all videos have timestamps (one-to-many). Exclude those somehow
with: {
timestamps: true
},
});

// Below should not be done in memory.
return allVideos.filter(
(video) => video.timestamps.length > 0
);
const allVideos = await db.query.videos.findMany({
where: // Not all videos have timestamps (one-to-many). Exclude those somehow
with: {
timestamps: true
},
});

// Below should not be done in memory.
return allVideos.filter(
(video) => video.timestamps.length > 0
);
Can't seem to find any examples of this in the docs. Any help would be greatly appreciated, thanks.
147 replies