There was an issue. Reason: syntax error at or near "null". Table: null Column: null
fernando-s97 opened this issue · 2 comments
I'm learning aqueduct. After running dart pub run aqueduct db generate
and dart pub run aqueduct db upgrade --connect postgres://mobile:mobile@localhost:5432/ccd
, I get the the following output. What's wrong (and how can I debug this kind of error)?
-- Aqueduct CLI Version: 3.3.0+1
-- Aqueduct project version: 3.3.0+1
-- Updating to version 1 on new database...
PostgreSQL connecting, mobile@localhost:5432/ccd.
Initializating database...
CREATE TABLE _aqueduct_version_pgsql (versionNumber INT NOT NULL UNIQUE,dateOfUpgrade TIMESTAMP NOT NULL)
Applying migration version 1...
CREATE TABLE _authclient (id TEXT PRIMARY KEY,hashedSecret TEXT NULL,salt TEXT NULL,redirectURI TEXT NULL,allowedScope TEXT NULL)
CREATE TABLE _authtoken (id BIGSERIAL PRIMARY KEY,code TEXT NULL UNIQUE,accessToken TEXT NULL UNIQUE,refreshToken TEXT NULL UNIQUE,scope TEXT NULL,issueDate TIMESTAMP NOT NULL,expirationDate TIMESTAMP NOT NULL,type TEXT NULL)
CREATE INDEX _authtoken_code_idx ON _authtoken (code)
CREATE INDEX _authtoken_accessToken_idx ON _authtoken (accessToken)
CREATE INDEX _authtoken_refreshToken_idx ON _authtoken (refreshToken)
CREATE INDEX _authtoken_expirationDate_idx ON _authtoken (expirationDate)
CREATE INDEX _authtoken_type_idx ON _authtoken (type)
CREATE TABLE _Graduate (name TEXT NOT NULL,program TEXT NOT NULL,institution TEXT NOT NULL,clientCode TEXT NOT NULL UNIQUE,project TEXT NOT NULL,graduationDate TIMESTAMP NOT NULL,id BIGSERIAL PRIMARY KEY,username TEXT NOT NULL UNIQUE,hashedPassword TEXT NOT NULL,salt TEXT NOT NULL)
CREATE INDEX _Graduate_username_idx ON _Graduate (username)
CREATE TABLE _Event (id BIGSERIAL PRIMARY KEY,flyerUrl TEXT NOT NULL,name TEXT NOT NULL UNIQUE,beginDateTime TIMESTAMP NOT NULL,endDateTime TIMESTAMP NULL,address TEXT NOT NULL,discount TEXT NOT NULL,facebook TEXT NULL)
CREATE TABLE _Partner (id BIGSERIAL PRIMARY KEY,logoUrl TEXT NOT NULL,name TEXT NOT NULL UNIQUE,address TEXT NOT NULL,phone TEXT NULL,facebook TEXT NULL,instagram TEXT NULL,discount TEXT NOT NULL,segments null NOT NULL)
*** There was an issue. Reason: syntax error at or near "null". Table: null Column: null
PostgreSQL version
$ psql --version
psql (PostgreSQL) 10.15 (Ubuntu 10.15-0ubuntu0.18.04.1)
Migration file
import 'dart:async';
import 'package:aqueduct/aqueduct.dart';
class Migration1 extends Migration {
@override
Future upgrade() async {
database.createTable(SchemaTable("_authclient", [SchemaColumn("id", ManagedPropertyType.string, isPrimaryKey: true, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("hashedSecret", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("salt", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("redirectURI", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("allowedScope", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false)]));
database.createTable(SchemaTable("_authtoken", [SchemaColumn("id", ManagedPropertyType.bigInteger, isPrimaryKey: true, autoincrement: true, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("code", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: true, isNullable: true, isUnique: true),SchemaColumn("accessToken", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: true, isNullable: true, isUnique: true),SchemaColumn("refreshToken", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: true, isNullable: true, isUnique: true),SchemaColumn("scope", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("issueDate", ManagedPropertyType.datetime, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("expirationDate", ManagedPropertyType.datetime, isPrimaryKey: false, autoincrement: false, isIndexed: true, isNullable: false, isUnique: false),SchemaColumn("type", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: true, isNullable: true, isUnique: false)]));
database.createTable(SchemaTable("_Graduate", [SchemaColumn("name", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("program", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("institution", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("clientCode", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: true),SchemaColumn("project", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("graduationDate", ManagedPropertyType.datetime, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("id", ManagedPropertyType.bigInteger, isPrimaryKey: true, autoincrement: true, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("username", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: true, isNullable: false, isUnique: true),SchemaColumn("hashedPassword", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("salt", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false)]));
database.createTable(SchemaTable("_Event", [SchemaColumn("id", ManagedPropertyType.bigInteger, isPrimaryKey: true, autoincrement: true, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("flyerUrl", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("name", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: true),SchemaColumn("beginDateTime", ManagedPropertyType.datetime, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("endDateTime", ManagedPropertyType.datetime, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("address", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("discount", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("facebook", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false)]));
database.createTable(SchemaTable("_Partner", [SchemaColumn("id", ManagedPropertyType.bigInteger, isPrimaryKey: true, autoincrement: true, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("logoUrl", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("name", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: true),SchemaColumn("address", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("phone", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("facebook", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("instagram", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: true, isUnique: false),SchemaColumn("discount", ManagedPropertyType.string, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false),SchemaColumn("segments", null, isPrimaryKey: false, autoincrement: false, isIndexed: false, isNullable: false, isUnique: false)]));
database.addColumn("_authtoken", SchemaColumn.relationship("resourceOwner", ManagedPropertyType.bigInteger, relatedTableName: "_Graduate", relatedColumnName: "id", rule: DeleteRule.cascade, isNullable: false, isUnique: false));
database.addColumn("_authtoken", SchemaColumn.relationship("client", ManagedPropertyType.string, relatedTableName: "_authclient", relatedColumnName: "id", rule: DeleteRule.cascade, isNullable: false, isUnique: false));
}
@override
Future downgrade() async {}
@override
Future seed() async {}
}
Models
import 'package:aqueduct/aqueduct.dart';
class Event extends ManagedObject<_Event> implements _Event {}
class _Event {
@primaryKey
int id;
@Column()
String flyerUrl;
@Column(unique: true)
String name;
@Column()
DateTime beginDateTime;
@Column(nullable: true)
DateTime endDateTime;
@Column()
String address;
@Column()
String discount;
@Column(nullable: true)
String facebook;
}
import 'package:aqueduct/aqueduct.dart';
import 'package:aqueduct/managed_auth.dart';
class Graduate extends ManagedObject<_Graduate>
implements _Graduate, ManagedAuthResourceOwner<_Graduate> {}
class _Graduate extends ResourceOwnerTableDefinition {
@Column()
String name;
@Column()
String program;
@Column()
String institution;
@Column(unique: true)
String clientCode;
@Column()
String project;
@Column()
DateTime graduationDate;
}
import 'package:aqueduct/aqueduct.dart';
class Partner extends ManagedObject<_Partner> implements _Partner {}
class _Partner {
@primaryKey
int id;
@Column()
String logoUrl;
@Column(unique: true)
String name;
@Column()
String address;
@Column(nullable: true)
String phone;
@Column(nullable: true)
String facebook;
@Column(nullable: true)
String instagram;
@Column()
String discount;
@Column()
List<String> segments;
}
In the _Partner
model you seems to have a propery segments
which type is null in the migration. Can you post the model so I can help you fix it?
@Reductions Question updated with models!
I didn't realize it. In fact, this migration file is the second version. I had these models with different properties before and generated the migration file for these models, but when I changed the Graduate model to work with OAuth, I tried to generate the migration file again, but it didn't work, so I had to delete this migration file to be able to generate a new one.
I say this because in the first migration file I had no problems, and the only changes made were in the Graduate model...