UNPKG

@t1mmen/srtd

Version:

Supabase Repeatable Template Definitions (srtd): 🪄 Live-reloading SQL templates for Supabase DX. Make your database changes reviewable and migrations maintainable! 🚀

26 lines • 914 B
/** * Generate the next unique migration timestamp. * * This is a PURE function - it does not mutate any state. * The caller is responsible for updating lastTimestamp in the build log. * * @param lastTimestamp - The last timestamp used (from build log) * @returns Object containing the new timestamp and the value to store as lastTimestamp */ export function getNextTimestamp(lastTimestamp) { const now = new Date(); const timestamp = now.toISOString().replace(/\D/g, '').slice(0, 14); if (timestamp <= lastTimestamp) { // Clock hasn't advanced past last timestamp, increment const nextTimestamp = (BigInt(lastTimestamp) + 1n).toString(); return { timestamp: nextTimestamp, newLastTimestamp: nextTimestamp, }; } return { timestamp, newLastTimestamp: timestamp, }; } //# sourceMappingURL=getNextTimestamp.js.map