I have a a following model.
When the server wants to migrate the table into empty database it is crashing deep down in async.
When exclude some fields from the prepare method it is creating without crash.
The crash or success depends on length of excluded fieldname if i exclude long field name or more fields then it will not crash, if I exclude only one short field it crashing.
import Foundation
import FluentMySQL
import Vapor
final class CrashTest : MySQLModel {
static let entity = "crashtest"
static let idKey = \CrashTest.profile_id
// MARK: Properties start
var profile_id: UUID?
var device_id: String
var created: Date?
var email: String?
var terms_date: Date?
var premium_from: Date?
var premium_until: Date?
var laty: Double?
var lngx: Double?
var location_date: Date?
var last_seen: Date?
var last_avatar: Date?
var report_count: Int
var report_count_overall: Int
var report_by: String?
var logged_in: Bool
var gender: String?
var search_gender: String?
var likes_out: String?
var likes_in: String?
var match_list: String?
var ignore_list: String?
var blocked_users: String?
var blocked_by: String?
var premium_pushed: Bool
var invite_used: Bool
var poke_sent: Date?
var whatsup_balance: Bool
var gift_period_until: Date?
var token: String?
var time_zone: String?
var badge: Int
var incognito: Bool
var incognito_text: String?
var area_notifications: Bool
var sales: Bool
var source_token: String?
var source_place: UUID?
var source_partner: UUID?
var source_identified: Bool
// MARK: init
init(profile_id: UUID? = nil,
device_id: String,
created: Date? = nil,
email: String? = nil,
terms_date: Date? = nil,
premium_from: Date? = nil,
premium_until: Date? = nil,
laty: Double? = nil,
lngx: Double? = nil,
location_date: Date? = nil,
last_seen: Date? = nil,
last_avatar: Date? = nil,
report_count: Int = 0,
report_count_overall: Int = 0,
report_by: String? = nil,
logged_in: Bool = true,
gender: String? = nil,
search_gender: String? = nil,
likes_out: String? = nil,
likes_in: String? = nil,
match_list: String? = nil,
ignore_list: String? = nil,
blocked_users: String? = nil,
blocked_by: String? = nil,
premium_pushed: Bool = false,
invite_used: Bool = false,
poke_sent: Date? = nil,
whatsup_balance: Bool = false,
gift_period_until: Date? = nil,
token: String? = nil,
time_zone: String? = nil,
badge: Int = 0,
incognito: Bool = false,
incognito_text: String? = nil,
area_notifications: Bool = true,
sales: Bool = false,
source_token: String? = nil,
source_place: UUID? = nil,
source_partner: UUID? = nil,
source_identified: Bool = false)
{
self.profile_id = profile_id
self.device_id = device_id
self.created = created
self.email = email
self.terms_date = terms_date
self.premium_from = premium_from
self.premium_until = premium_until
self.laty = laty
self.lngx = lngx
self.location_date = location_date
self.last_seen = last_seen
self.last_avatar = last_avatar
self.report_count = report_count
self.report_count_overall = report_count_overall
self.report_by = report_by
self.logged_in = logged_in
self.gender = gender
self.search_gender = search_gender
self.likes_out = likes_out
self.likes_in = likes_in
self.match_list = match_list
self.ignore_list = ignore_list
self.blocked_users = blocked_users
self.blocked_by = blocked_by
self.premium_pushed = premium_pushed
self.invite_used = invite_used
self.poke_sent = poke_sent
self.whatsup_balance = whatsup_balance
self.gift_period_until = gift_period_until
self.token = token
self.time_zone = time_zone
self.badge = badge
self.incognito = incognito
self.incognito_text = incognito_text
self.area_notifications = area_notifications
self.sales = sales
self.source_token = source_token
self.source_place = source_place
self.source_partner = source_partner
self.source_identified = source_identified
}
}
extension CrashTest: Migration {
static func prepare(on connection: MySQLConnection) -> Future<Void> {
return MySQLDatabase.create(self, on: connection) { builder in
builder.field(type: .varChar(length: 64, binary: true), for: \CrashTest.profile_id)
builder.field(type: .varChar(length: 128), for: \CrashTest.device_id, isOptional: false)
builder.field(type: .datetime(), for: \CrashTest.created ,isOptional: true)
builder.field(type: .varChar(length: 100), for: \CrashTest.email, isOptional: true)
builder.field(type: .datetime(), for: \CrashTest.terms_date, isOptional: true)
builder.field(type: .datetime(), for: \CrashTest.premium_from, isOptional: true)
builder.field(type: .datetime(), for: \CrashTest.premium_until, isOptional: true)
builder.field(type: .double(), for: \CrashTest.laty, isOptional: true)
builder.field(type: .double(), for: \CrashTest.lngx, isOptional:true)
builder.field(type: .datetime(), for: \CrashTest.location_date, isOptional: true)
builder.field(type: .datetime(), for: \CrashTest.last_seen, isOptional:true )
builder.field(type: .datetime(), for: \CrashTest.last_avatar, isOptional: true)
builder.field(type: .int64(), for: \CrashTest.report_count, isOptional: false)
builder.field(type: .int64(), for: \CrashTest.report_count_overall, isOptional: false)
builder.field(type: .text(), for: \CrashTest.report_by, isOptional: true)
builder.field(type: .int8(), for: \CrashTest.logged_in, isOptional: false)
builder.field(type: .varChar(length:1), for: \CrashTest.gender, isOptional: true)
builder.field(type: .varChar(length:1), for: \CrashTest.search_gender, isOptional: true)
builder.field(type: .text(), for: \CrashTest.likes_out, isOptional: true)
builder.field(type: .text(), for: \CrashTest.likes_in, isOptional: true)
builder.field(type: .text(), for: \CrashTest.match_list, isOptional: true)
builder.field(type: .text(), for: \CrashTest.ignore_list, isOptional: true)
builder.field(type: .text(), for: \CrashTest.blocked_users, isOptional: true)
builder.field(type: .text(), for: \CrashTest.blocked_by, isOptional: true)
builder.field(type: .int8(), for: \CrashTest.premium_pushed, isOptional: true)
builder.field(type: .int8(), for: \CrashTest.invite_used, isOptional: false)
builder.field(type: .datetime(), for: \CrashTest.poke_sent, isOptional: true)
builder.field(type: .int8(), for: \CrashTest.whatsup_balance, isOptional: false)
builder.field(type: .datetime(), for: \CrashTest.gift_period_until, isOptional: true)
builder.field(type: .varChar(length: 15), for: \CrashTest.token, isOptional: true)
builder.field(type: .varChar(length: 8), for: \CrashTest.time_zone, isOptional: true)
builder.field(type: .int64(), for: \CrashTest.badge, isOptional: false)
builder.field(type: .int8(), for: \CrashTest.incognito, isOptional: false)
builder.field(type: .text(), for: \CrashTest.incognito_text, isOptional: true)
builder.field(type: .int8(), for: \CrashTest.area_notifications, isOptional: false)
builder.field(type: .int8(), for: \CrashTest.sales, isOptional: false)
builder.field(type: .varChar(length: 20), for: \CrashTest.source_token, isOptional: true)
builder.field(type: .varChar(length: 64, binary: true), for: \CrashTest.source_place, isOptional: true)
builder.field(type: .varChar(length: 64, binary:true), for: \CrashTest.source_partner, isOptional: true)
builder.field(type: .int8(), for: \CrashTest.source_identified, isOptional: false)
}
}
}
extension CrashTest: Content {}
extension CrashTest: Parameter {}