Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Fix bug with NOT null constraint

Acho Arnoldd223e0df4b97
diff --git a/android/build.gradle b/android/build.gradle
index bb5e2f77..8157d122 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -17,8 +17,8 @@ buildscript {
}
plugins {
- id 'com.android.application' version '8.8.0' apply false
- id 'com.android.library' version '8.8.0' apply false
+ id 'com.android.application' version '8.8.2' apply false
+ id 'com.android.library' version '8.8.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
diff --git a/api/pkg/di/container.go b/api/pkg/di/container.go
index cd21e074..df7a0738 100644
--- a/api/pkg/di/container.go
+++ b/api/pkg/di/container.go
@@ -321,11 +321,6 @@ func (container *Container) DB() (db *gorm.DB) {
container.logger.Debug(fmt.Sprintf("Running migrations for %T", db))
- // This prevents a bug in the Gorm AutoMigrate where it tries to delete this no existent constraints
- db.Exec(`
-ALTER TABLE users ADD CONSTRAINT IF NOT EXISTS uni_users_api_key CHECK (api_key IS NOT NULL);
-ALTER TABLE discords ADD CONSTRAINT IF NOT EXISTS uni_discords_server_id CHECK (server_id IS NOT NULL);`)
-
if err = db.AutoMigrate(&entities.Message{}); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Message{})))
}
diff --git a/api/pkg/entities/discord.go b/api/pkg/entities/discord.go
index fd5f2b21..13b2e903 100644
--- a/api/pkg/entities/discord.go
+++ b/api/pkg/entities/discord.go
@@ -11,7 +11,7 @@ type Discord struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
UserID UserID `json:"user_id" gorm:"index" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
Name string `json:"name" example:"Game Server"`
- ServerID string `json:"server_id" gorm:"uniqueIndex:idx_discords_server_id" example:"1095778291488653372"`
+ ServerID string `json:"server_id" gorm:"uniqueIndex:idx_discords_server_id;NOT NULL" example:"1095778291488653372"`
IncomingChannelID string `json:"incoming_channel_id" example:"1095780203256627291"`
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`
diff --git a/api/pkg/entities/phone_api_key.go b/api/pkg/entities/phone_api_key.go
index 949dea52..8aef7136 100644
--- a/api/pkg/entities/phone_api_key.go
+++ b/api/pkg/entities/phone_api_key.go
@@ -15,7 +15,7 @@ type PhoneAPIKey struct {
UserEmail string `json:"user_email" example:"[email protected]"`
PhoneNumbers pq.StringArray `json:"phone_numbers" example:"[+18005550199,+18005550100]" gorm:"type:text[]" swaggertype:"array,string"`
PhoneIDs pq.StringArray `json:"phone_ids" example:"[32343a19-da5e-4b1b-a767-3298a73703cb,32343a19-da5e-4b1b-a767-3298a73703cc]" gorm:"type:text[]" swaggertype:"array,string"`
- APIKey string `json:"api_key" gorm:"uniqueIndex:idx_phone_api_key__api_key" example:"pk_DGW8NwQp7mxKaSZ72Xq9v6xxxxx"`
+ APIKey string `json:"api_key" gorm:"uniqueIndex:idx_phone_api_key__api_key;NOT NULL" example:"pk_DGW8NwQp7mxKaSZ72Xq9v6xxxxx"`
CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:02.302718+03:00"`
}
diff --git a/api/pkg/entities/user.go b/api/pkg/entities/user.go
index ff560ad0..0d4cbbe7 100644
--- a/api/pkg/entities/user.go
+++ b/api/pkg/entities/user.go
@@ -74,7 +74,7 @@ const SubscriptionName20KYearly = SubscriptionName("20k-yearly")
type User struct {
ID UserID `json:"id" gorm:"primaryKey;type:string;" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
Email string `json:"email" example:"[email protected]"`
- APIKey string `json:"api_key" gorm:"uniqueIndex:idx_users_api_key" example:"x-api-key"`
+ APIKey string `json:"api_key" gorm:"uniqueIndex:idx_users_api_key;NOT NULL" example:"x-api-key"`
Timezone string `json:"timezone" example:"Europe/Helsinki" gorm:"default:Africa/Accra"`
ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
SubscriptionName SubscriptionName `json:"subscription_name" example:"free"`