rubenv / rubenv/sql-migrate

transaction failed.

Open
#111 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
3.4k
Forks
292
PR merge metrics
No merged PRs in 30d

Description

Here is my migration file, there is a syntax error for test intentionally . When I use command line sql-migrate up, error occurred, migrations table not changed, but two tables are created successfully.

-- +migrate Up
CREATE TABLE `users` (
    `id` bigint(20) NOT NULL,
    `login_name` varchar(50) NOT NULL,
    `password` varchar(50) NOT NULL,
    `real_name` varchar(50) NOT NULL,
    `mobile` varchar(50) NOT NULL,
    `email` varchar(50) NOT NULL,
    `role` bigint(20) NOT NULL,
    `last_login` int(11) NOT NULL,
    `last_ip` int(11) NOT NULL,
    `deleted` int(11) NOT NULL,
    `created_at` int(11) NOT NULL,
    `updated_at` int(11) NOT NULL,
    PRIMARY KEY (`id`)
);
CREATE TABLE `roles` (
    `id` bigint(20) NOT NULL,
    `name` varchar(50) NOT NULL,
    `permissions` varchar(500) NOT NULL,
    `deleted` int(11) NOT NULL,
    `created_at` int(11) NOT NULL,
    `updated_at` int(11) NOT NULL,
    PRIMARY KEY (`id`)
);

INSERT INTO roles(id, name, permissions, deleted, created_at, updated_at)
VALUES(1, 'System', '', 0, 1505874156,1505874156);

INSERT INTO users(id, login_name, password, real_name, mobile, email, role, last_login, last_ip, deleted, created_at, updated_at)
VALUES(1,'System','e10adc3949ba59abbe56e057f20f883e', 'admin', '15308188844', 'admin@admin.com', 0, 1505874156, 'x', 0, 1505874156, 1505874156);
-- +migrate Down
DROP TABLE `users`;
DROP TABLE `roles`;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report by running the supplied migration with the sql-migrate up command and a deliberately failing statement. Start at the command-line migration entry point and inspect how transaction boundaries and migration-record updates are handled; done means the observed behavior is explained and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.