implement atlas for db migration
This commit is contained in:
@@ -32,26 +32,6 @@ func NewDatabaseService(db *sql.DB) *DatabaseService {
|
||||
return &DatabaseService{db: db}
|
||||
}
|
||||
|
||||
func (s *DatabaseService) CreateTable() error {
|
||||
_, err := s.db.Exec(`
|
||||
CREATE TABLE IF NOT EXISTS weather_readings (
|
||||
id SERIAL PRIMARY KEY,
|
||||
city TEXT NOT NULL,
|
||||
temp DOUBLE PRECISION NOT NULL,
|
||||
feels_like DOUBLE PRECISION NOT NULL,
|
||||
humidity INTEGER NOT NULL,
|
||||
conditions TEXT NOT NULL,
|
||||
fetched_at TIMESTAMP WITH TIME ZONE NOT NULL
|
||||
)
|
||||
`)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("failed to create table: %v", err)
|
||||
}
|
||||
fmt.Println("weather_readings table ready")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) SaveReading(weather models.WeatherResponse) (int, error) {
|
||||
conditions := ""
|
||||
if len(weather.Weather) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user