Ejemplo n.º 1
0
func (d *PostgresDialect) AfterCollectionCreate(info *db.ModelInfo) apperror.Error {
	for _, attr := range info.Attributes() {
		// Alter sequences to start at 1 instead of 0.
		if attr.AutoIncrement() {
			stmt := fmt.Sprintf("ALTER SEQUENCE %v_%v_seq RESTART WITH %v", info.BackendName(), attr.BackendName(), 1)
			if _, err := d.backend.SqlExec(stmt); err != nil {
				return apperror.Wrap(err, "sql_error")
			}
		}
	}

	return nil
}