Skip to content

Support MariaDB default values for timestamp #4105

Description

@critrun

What do you want to change?

If I create a table like for example:

CREATE TABLE IF NOT EXISTS `session` (
    `id` INT NOT NULL,
    `expiry` TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP + INTERVAL 30 DAY),
    PRIMARY KEY (`id`)
);

Currently this default for the expiry will not work as it causes syntax error, as this isn't a feature for mysql but only mariadb from my understanding. It would be nice to have these more programmatic defaults work with sqlc.

What database engines need to be changed?

MySQL

What programming language backends need to be changed?

No response

Activity

  1. tebruno99 commented on Nov 25, 2025

    @tebruno99

    I have hit this issue as well with table creation succeeds on mysql 8.x but fails with sqlc

    create table invitations
    (
        id              bigint auto_increment primary key,
        email           varchar(255)                                    not null,
        code            varchar(36)                                     not null,
        expires         datetime default ((now() + interval 90 minute)) not null,
        created_at      datetime default now()                          not null
    );
    
    sqlc/mysql/migrations/0232_schema_invitations.up.sql:8:38: syntax error near "+ INTERVAL 90 MINUTE),"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions