fixes
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions

This commit is contained in:
Dmitry 2025-12-15 00:45:52 +03:00
parent 0914a62d35
commit 7c1e2bcaf7
11 changed files with 88 additions and 63 deletions

View file

@ -35,15 +35,10 @@ mixin SoftDeleteMixin<T extends Table, D> on DatabaseAccessor<AppDatabase> {
SimpleSelectStatement<T, D> selectActive() {
return select(table)
..where((t) {
// Проблема: через dynamic Drift может неправильно определить тип boolean
// и сгенерировать SQL, который сравнивает boolean с integer
// Решение: используем прямое SQL выражение для правильного сравнения boolean
// В PostgreSQL имена колонок в snake_case: is_deleted
final tableName = table.actualTableName;
return CustomExpression<bool>(
'"$tableName"."is_deleted" = FALSE',
precedence: Precedence.comparison,
);
// После удаления customConstraint('') из boolean колонок,
// Drift корректно определяет тип boolean и генерирует правильный SQL
final isDeletedColumn = (t as dynamic).isDeleted;
return isDeletedColumn.equals(false);
});
}

View file

@ -56,7 +56,9 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("admin" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _userSettingsMeta = const VerificationMeta(
@ -116,7 +118,9 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
@override
@ -1520,7 +1524,9 @@ class $TokensTable extends Tokens with TableInfo<$TokensTable, Token> {
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -2018,7 +2024,9 @@ class $RefreshTokensTable extends RefreshTokens
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_blacklisted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _createdAtMeta = const VerificationMeta(
@ -2056,7 +2064,9 @@ class $RefreshTokensTable extends RefreshTokens
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -2628,7 +2638,9 @@ class $TelegramAuthCodesTable extends TelegramAuthCodes
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -3346,7 +3358,9 @@ class $CardPacksTable extends CardPacks
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("enabled" IN (0, 1))',
),
defaultValue: const Constant(true),
);
@override
@ -3449,7 +3463,9 @@ class $CardPacksTable extends CardPacks
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
@override
@ -4431,7 +4447,9 @@ class $GameCardsTable extends GameCards
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
@override
@ -6584,7 +6602,9 @@ class $SubscriptionPlansTable extends SubscriptionPlans
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
@override
@ -7748,7 +7768,9 @@ class $PaymentsTable extends Payments with TableInfo<$PaymentsTable, Payment> {
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -8535,7 +8557,9 @@ class $TestsTable extends Tests with TableInfo<$TestsTable, Test> {
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -9180,7 +9204,9 @@ class $TestQuestionsTable extends TestQuestions
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -12927,7 +12953,9 @@ class $PromoCodesCampaignsTable extends PromoCodesCampaigns
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -13754,7 +13782,9 @@ class $PromoCodesTable extends PromoCodes
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -14336,7 +14366,9 @@ class $DiscountCampaignsTable extends DiscountCampaigns
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -14947,7 +14979,9 @@ class $DiscountsTable extends Discounts
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(
@ -15832,7 +15866,9 @@ class $StudySessionsTable extends StudySessions
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: '',
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("is_deleted" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _deletedAtMeta = const VerificationMeta(

View file

@ -18,8 +18,7 @@ class Tokens extends Table {
.withDefault(now())();
Column<PgDateTime> get expires => customType(PgTypes.timestampWithTimezone)();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')();
.withDefault(const Constant(false))();
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();
@ -43,15 +42,13 @@ class RefreshTokens extends Table {
TextColumn get jti => text().unique()(); // JWT ID
BoolColumn get isBlacklisted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))(); // PostgreSQL использует нативный BOOLEAN
Column<PgDateTime> get createdAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
Column<PgDateTime> get expiresAt => customType(PgTypes.timestampWithTimezone)();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')();
.withDefault(const Constant(false))();
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();
@ -81,8 +78,7 @@ class TelegramAuthCodes extends Table {
.withDefault(now())();
Column<PgDateTime> get expiresAt => customType(PgTypes.timestampWithTimezone)();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')();
.withDefault(const Constant(false))();
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();

View file

@ -28,8 +28,8 @@ class DiscountCampaigns extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))();
// PostgreSQL использует нативный BOOLEAN
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();
@ -59,8 +59,8 @@ class Discounts extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))();
// PostgreSQL использует нативный BOOLEAN
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();

View file

@ -22,8 +22,8 @@ class CardPacks extends Table {
TextColumn get version => text().nullable()();
IntColumn get order => integer().withDefault(const Constant(0))();
BoolColumn get enabled => boolean()
.withDefault(const Constant(true))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(true))();
// PostgreSQL использует нативный BOOLEAN
// Порядок карточек (JSON array of IDs)
TextColumn get cardsOrder => text()
@ -45,8 +45,8 @@ class CardPacks extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))();
// PostgreSQL использует нативный BOOLEAN
@override
Set<Column> get primaryKey => {id};
@ -81,8 +81,8 @@ class GameCards extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))();
// PostgreSQL использует нативный BOOLEAN
@override
Set<Column> get primaryKey => {id};

View file

@ -35,8 +35,8 @@ class Payments extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')();
.withDefault(const Constant(false))();
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();

View file

@ -38,8 +38,8 @@ class PromoCodesCampaigns extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))();
// PostgreSQL использует нативный BOOLEAN
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();
@ -69,8 +69,8 @@ class PromoCodes extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')();
.withDefault(const Constant(false))();
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();

View file

@ -30,8 +30,8 @@ class StudySessions extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')();
.withDefault(const Constant(false))();
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();

View file

@ -32,8 +32,8 @@ class SubscriptionPlans extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))();
// PostgreSQL использует нативный BOOLEAN
@override
Set<Column> get primaryKey => {id};

View file

@ -22,8 +22,8 @@ class Tests extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))();
// PostgreSQL использует нативный BOOLEAN
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();
@ -49,8 +49,8 @@ class TestQuestions extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')();
.withDefault(const Constant(false))();
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
.nullable()();

View file

@ -11,8 +11,7 @@ class Users extends Table {
TextColumn get name => text().nullable()();
TextColumn get email => text().nullable()();
BoolColumn get admin => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))(); // PostgreSQL использует нативный BOOLEAN
// UserSettings (JSON)
TextColumn get userSettings => text().nullable()();
@ -29,8 +28,7 @@ class Users extends Table {
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
.withDefault(now())();
BoolColumn get isDeleted => boolean()
.withDefault(const Constant(false))
.customConstraint('')(); // PostgreSQL использует нативный BOOLEAN
.withDefault(const Constant(false))(); // PostgreSQL использует нативный BOOLEAN
@override
Set<Column> get primaryKey => {id};