From c8832ee84acb95b3071a03ec55b0204a6bddd10b Mon Sep 17 00:00:00 2001 From: Jarrod Seccombe Date: Sun, 17 Nov 2024 23:26:25 -0500 Subject: [PATCH] imager: fix style warnings and remove old schema file --- internal/database/connection.go | 4 +- internal/imager/circuit.go | 6 +- internal/imager/constructor.go | 18 ++-- internal/imager/download.go | 16 ++-- internal/imager/driver.go | 12 +-- internal/imager/imager.go | 13 ++- internal/imager/laptime.go | 6 +- internal/imager/pitstop.go | 6 +- internal/imager/qualifying.go | 6 +- internal/imager/race.go | 6 +- internal/imager/result.go | 12 +-- internal/imager/season.go | 6 +- internal/imager/status.go | 6 +- sql/schema.sql | 163 -------------------------------- 14 files changed, 63 insertions(+), 217 deletions(-) delete mode 100644 sql/schema.sql diff --git a/internal/database/connection.go b/internal/database/connection.go index f6ec8ac..c595f9f 100644 --- a/internal/database/connection.go +++ b/internal/database/connection.go @@ -15,7 +15,7 @@ func Connect(ctx context.Context) (*pgxpool.Pool, error) { config, err := pgxpool.ParseConfig(connString) if err != nil { - return nil, fmt.Errorf("Error parsing connection string: %w", err) + return nil, fmt.Errorf("error parsing connection string: %w", err) } config.AfterConnect = func(ctx context.Context, c *pgx.Conn) error { @@ -25,7 +25,7 @@ func Connect(ctx context.Context) (*pgxpool.Pool, error) { pool, err := pgxpool.NewWithConfig(ctx, config) if err != nil { - return nil, fmt.Errorf("Error creating connection: %w", err) + return nil, fmt.Errorf("error creating connection: %w", err) } return pool, nil diff --git a/internal/imager/circuit.go b/internal/imager/circuit.go index 92d4401..a79d794 100644 --- a/internal/imager/circuit.go +++ b/internal/imager/circuit.go @@ -26,14 +26,14 @@ type circuit struct { func (i Imager) loadCircuits(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/circuits.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening circuits CSV file: %w", err) + return fmt.Errorf("error opening circuits CSV file: %w", err) } defer file.Close() var circuits []*circuit if err = gocsv.UnmarshalFile(file, &circuits); err != nil { - return fmt.Errorf("Error marshaling circuits CSV file: %w", err) + return fmt.Errorf("error marshaling circuits CSV file: %w", err) } records := []database.SaveCircuitsParams{} @@ -54,7 +54,7 @@ func (i Imager) loadCircuits(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveCircuits(ctx, records) if err != nil { - return fmt.Errorf("Error saving circuits: %w", err) + return fmt.Errorf("error saving circuits: %w", err) } fmt.Println("[Circuits] seeding complete") diff --git a/internal/imager/constructor.go b/internal/imager/constructor.go index e800469..9339e3a 100644 --- a/internal/imager/constructor.go +++ b/internal/imager/constructor.go @@ -22,14 +22,14 @@ type constructor struct { func (i Imager) loadConstructors(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/constructors.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening constructors CSV file: %w", err) + return fmt.Errorf("error opening constructors CSV file: %w", err) } defer file.Close() var constructors []*constructor if err = gocsv.UnmarshalFile(file, &constructors); err != nil { - return fmt.Errorf("Error marshaling constructors CSV file: %w", err) + return fmt.Errorf("error marshaling constructors CSV file: %w", err) } records := []database.SaveConstructorsParams{} @@ -46,7 +46,7 @@ func (i Imager) loadConstructors(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveConstructors(ctx, records) if err != nil { - return fmt.Errorf("Error saving constructors: %w", err) + return fmt.Errorf("error saving constructors: %w", err) } return nil @@ -63,14 +63,14 @@ type constructorResult struct { func (i Imager) loadConstructorResults(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/constructor_results.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening constructor results CSV file: %w", err) + return fmt.Errorf("error opening constructor results CSV file: %w", err) } defer file.Close() var results []*constructorResult if err = gocsv.UnmarshalFile(file, &results); err != nil { - return fmt.Errorf("Error marshaling constructor results CSV file: %w", err) + return fmt.Errorf("error marshaling constructor results CSV file: %w", err) } records := []database.SaveConstructorResultsParams{} @@ -87,7 +87,7 @@ func (i Imager) loadConstructorResults(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveConstructorResults(ctx, records) if err != nil { - return fmt.Errorf("Error saving constructor results: %w", err) + return fmt.Errorf("error saving constructor results: %w", err) } fmt.Println("[Constructor Results] seeding complete") @@ -107,14 +107,14 @@ type constructorStanding struct { func (i Imager) loadConstructorStandings(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/constructor_standings.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening constructor standings CSV file: %w", err) + return fmt.Errorf("error opening constructor standings CSV file: %w", err) } defer file.Close() var standings []*constructorStanding if err = gocsv.UnmarshalFile(file, &standings); err != nil { - return fmt.Errorf("Error marshaling constructor standings CSV file: %w", err) + return fmt.Errorf("error marshaling constructor standings CSV file: %w", err) } records := []database.SaveConstructorStandingsParams{} @@ -133,7 +133,7 @@ func (i Imager) loadConstructorStandings(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveConstructorStandings(ctx, records) if err != nil { - return fmt.Errorf("Error saving constructor standings: %w", err) + return fmt.Errorf("error saving constructor standings: %w", err) } fmt.Println("[Constructor Standings] seeding complete") diff --git a/internal/imager/download.go b/internal/imager/download.go index 98749e7..e63778b 100644 --- a/internal/imager/download.go +++ b/internal/imager/download.go @@ -13,19 +13,19 @@ const zipName = "seed.zip" func FetchSeedData() error { out, err := os.Create(zipName) if err != nil { - return fmt.Errorf("Error creating seed file: %w", err) + return fmt.Errorf("error creating seed file: %w", err) } defer out.Close() resp, err := http.Get("http://ergast.com/downloads/f1db_csv.zip") if err != nil { - return fmt.Errorf("Error fetching seed data: %w", err) + return fmt.Errorf("error fetching seed data: %w", err) } defer resp.Body.Close() _, err = io.Copy(out, resp.Body) if err != nil { - return fmt.Errorf("Error saving seed data: %w", err) + return fmt.Errorf("error saving seed data: %w", err) } return UnzipSeedData() @@ -34,31 +34,31 @@ func FetchSeedData() error { func UnzipSeedData() error { r, err := zip.OpenReader(zipName) if err != nil { - return fmt.Errorf("Error opening zipfile: %w", err) + return fmt.Errorf("error opening zipfile: %w", err) } defer r.Close() err = os.MkdirAll("data", 0755) if err != nil { - return fmt.Errorf("Error creating data dir: %w", err) + return fmt.Errorf("error creating data dir: %w", err) } for _, f := range r.File { rc, err := f.Open() if err != nil { - return fmt.Errorf("Error extracting file %s: %w", f.Name, err) + return fmt.Errorf("error extracting file %s: %w", f.Name, err) } defer rc.Close() filePath := fmt.Sprintf("data/%s", f.Name) file, err := os.Create(filePath) if err != nil { - return fmt.Errorf("Error creating uncompressed file %s: %w", f.Name, err) + return fmt.Errorf("error creating uncompressed file %s: %w", f.Name, err) } _, err = io.Copy(file, rc) if err != nil { - return fmt.Errorf("Error decompressing file %s: %w", f.Name, err) + return fmt.Errorf("error decompressing file %s: %w", f.Name, err) } } diff --git a/internal/imager/driver.go b/internal/imager/driver.go index 3dd4ece..a0f24ae 100644 --- a/internal/imager/driver.go +++ b/internal/imager/driver.go @@ -26,14 +26,14 @@ type driver struct { func (i Imager) loadDrivers(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/drivers.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening driver CSV file: %w", err) + return fmt.Errorf("error opening driver CSV file: %w", err) } defer file.Close() var drivers []*driver if err = gocsv.UnmarshalFile(file, &drivers); err != nil { - return fmt.Errorf("Error marshaling driver CSV file: %w", err) + return fmt.Errorf("error marshaling driver CSV file: %w", err) } records := []database.SaveDriversParams{} @@ -54,7 +54,7 @@ func (i Imager) loadDrivers(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveDrivers(ctx, records) if err != nil { - return fmt.Errorf("Error saving drivers: %w", err) + return fmt.Errorf("error saving drivers: %w", err) } fmt.Println("[Drivers] seeding complete") @@ -74,14 +74,14 @@ type driverStanding struct { func (i Imager) loadDriverStandings(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/driver_standings.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening driver standings CSV file: %w", err) + return fmt.Errorf("error opening driver standings CSV file: %w", err) } defer file.Close() var standings []*driverStanding if err = gocsv.UnmarshalFile(file, &standings); err != nil { - return fmt.Errorf("Error marshaling driver standings CSV file: %w", err) + return fmt.Errorf("error marshaling driver standings CSV file: %w", err) } records := []database.SaveDriverStandingsParams{} @@ -100,7 +100,7 @@ func (i Imager) loadDriverStandings(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveDriverStandings(ctx, records) if err != nil { - return fmt.Errorf("Error saving driver standings: %w", err) + return fmt.Errorf("error saving driver standings: %w", err) } fmt.Println("[Driver Standings] seeding complete") diff --git a/internal/imager/imager.go b/internal/imager/imager.go index dd375a7..144eec4 100644 --- a/internal/imager/imager.go +++ b/internal/imager/imager.go @@ -21,14 +21,23 @@ func Run(ctx context.Context) error { tx, err := pool.Begin(ctx) if err != nil { - return fmt.Errorf("Error acquiring transaction: %w", err) + return fmt.Errorf("error acquiring transaction: %w", err) } + defer tx.Rollback(ctx) imager := Imager{ db: database.New(pool), } - return imager.Seed(ctx, tx) + if err = imager.Seed(ctx, tx); err != nil { + return err + } + + if err = tx.Commit(ctx); err != nil { + return err + } + + return nil } func (i Imager) Seed(ctx context.Context, tx pgx.Tx) error { diff --git a/internal/imager/laptime.go b/internal/imager/laptime.go index f57fa01..34af57b 100644 --- a/internal/imager/laptime.go +++ b/internal/imager/laptime.go @@ -22,14 +22,14 @@ type lapTime struct { func (i Imager) loadLapTimes(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/lap_times.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening lap times CSV file: %w", err) + return fmt.Errorf("error opening lap times CSV file: %w", err) } defer file.Close() var lapTimes []*lapTime if err = gocsv.UnmarshalFile(file, &lapTimes); err != nil { - return fmt.Errorf("Error marshaling lap times CSV file: %w", err) + return fmt.Errorf("error marshaling lap times CSV file: %w", err) } records := []database.SaveLapTimesParams{} @@ -47,7 +47,7 @@ func (i Imager) loadLapTimes(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveLapTimes(ctx, records) if err != nil { - return fmt.Errorf("Error saving lap times: %w", err) + return fmt.Errorf("error saving lap times: %w", err) } fmt.Println("[Lap Times] seeding complete") diff --git a/internal/imager/pitstop.go b/internal/imager/pitstop.go index 451dcda..ea296bd 100644 --- a/internal/imager/pitstop.go +++ b/internal/imager/pitstop.go @@ -23,14 +23,14 @@ type pitStop struct { func (i Imager) loadPitStops(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/pit_stops.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening pit stops CSV file: %w", err) + return fmt.Errorf("error opening pit stops CSV file: %w", err) } defer file.Close() var pitStops []*pitStop if err = gocsv.UnmarshalFile(file, &pitStops); err != nil { - return fmt.Errorf("Error marshaling pit stops CSV file: %w", err) + return fmt.Errorf("error marshaling pit stops CSV file: %w", err) } records := []database.SavePitStopsParams{} @@ -49,7 +49,7 @@ func (i Imager) loadPitStops(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SavePitStops(ctx, records) if err != nil { - return fmt.Errorf("Error saving pit stops: %w", err) + return fmt.Errorf("error saving pit stops: %w", err) } fmt.Println("[Pit Stops] seeding complete") diff --git a/internal/imager/qualifying.go b/internal/imager/qualifying.go index 2a43dc5..4bbb644 100644 --- a/internal/imager/qualifying.go +++ b/internal/imager/qualifying.go @@ -25,14 +25,14 @@ type qualifying struct { func (i Imager) loadQualifying(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/qualifying.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening qualifying CSV file: %w", err) + return fmt.Errorf("error opening qualifying CSV file: %w", err) } defer file.Close() var results []*qualifying if err = gocsv.UnmarshalFile(file, &results); err != nil { - return fmt.Errorf("Error marshaling qualifying CSV file: %w", err) + return fmt.Errorf("error marshaling qualifying CSV file: %w", err) } records := []database.SaveQualifyingResultsParams{} @@ -53,7 +53,7 @@ func (i Imager) loadQualifying(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveQualifyingResults(ctx, records) if err != nil { - return fmt.Errorf("Error saving qualifying results: %w", err) + return fmt.Errorf("error saving qualifying results: %w", err) } fmt.Println("[Qualifying] seeding complete") diff --git a/internal/imager/race.go b/internal/imager/race.go index d18dd7c..b801a12 100644 --- a/internal/imager/race.go +++ b/internal/imager/race.go @@ -34,14 +34,14 @@ type race struct { func (i Imager) loadRaces(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/races.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening races CSV file: %w", err) + return fmt.Errorf("error opening races CSV file: %w", err) } defer file.Close() var races []*race if err = gocsv.UnmarshalFile(file, &races); err != nil { - return fmt.Errorf("Error marshaling races CSV file: %w", err) + return fmt.Errorf("error marshaling races CSV file: %w", err) } records := []database.SaveRacesParams{} @@ -71,7 +71,7 @@ func (i Imager) loadRaces(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveRaces(ctx, records) if err != nil { - return fmt.Errorf("Error saving races: %w", err) + return fmt.Errorf("error saving races: %w", err) } fmt.Println("[Races] seeding complete") diff --git a/internal/imager/result.go b/internal/imager/result.go index 9b3827c..a5cd920 100644 --- a/internal/imager/result.go +++ b/internal/imager/result.go @@ -35,14 +35,14 @@ type result struct { func (i Imager) loadResults(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/results.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening results CSV file: %w", err) + return fmt.Errorf("error opening results CSV file: %w", err) } defer file.Close() var results []*result if err = gocsv.UnmarshalFile(file, &results); err != nil { - return fmt.Errorf("Error marshaling results CSV file: %w", err) + return fmt.Errorf("error marshaling results CSV file: %w", err) } records := []database.SaveResultsParams{} @@ -72,7 +72,7 @@ func (i Imager) loadResults(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveResults(ctx, records) if err != nil { - return fmt.Errorf("Error saving results: %w", err) + return fmt.Errorf("error saving results: %w", err) } fmt.Println("[Results] seeding complete") @@ -103,14 +103,14 @@ type sprintResult struct { func (i Imager) loadSprintResults(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/sprint_results.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening sprint results CSV file: %w", err) + return fmt.Errorf("error opening sprint results CSV file: %w", err) } defer file.Close() var results []*sprintResult if err = gocsv.UnmarshalFile(file, &results); err != nil { - return fmt.Errorf("Error marshaling sprint results CSV file: %w", err) + return fmt.Errorf("error marshaling sprint results CSV file: %w", err) } records := []database.SaveSprintResultsParams{} @@ -138,7 +138,7 @@ func (i Imager) loadSprintResults(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveSprintResults(ctx, records) if err != nil { - return fmt.Errorf("Error saving sprint results: %w", err) + return fmt.Errorf("error saving sprint results: %w", err) } fmt.Println("[Sprint Results] seeding complete") diff --git a/internal/imager/season.go b/internal/imager/season.go index ed75f12..8dd494e 100644 --- a/internal/imager/season.go +++ b/internal/imager/season.go @@ -18,14 +18,14 @@ type season struct { func (i Imager) loadSeasons(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/seasons.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening seasons CSV file: %w", err) + return fmt.Errorf("error opening seasons CSV file: %w", err) } defer file.Close() var seasons []*season if err = gocsv.UnmarshalFile(file, &seasons); err != nil { - return fmt.Errorf("Error marshaling seasons CSV file: %w", err) + return fmt.Errorf("error marshaling seasons CSV file: %w", err) } records := []database.SaveSeasonsParams{} @@ -39,7 +39,7 @@ func (i Imager) loadSeasons(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveSeasons(ctx, records) if err != nil { - return fmt.Errorf("Error saving seasons: %w", err) + return fmt.Errorf("error saving seasons: %w", err) } fmt.Println("[Seasons] seeding complete") diff --git a/internal/imager/status.go b/internal/imager/status.go index 9fc3aa1..411923b 100644 --- a/internal/imager/status.go +++ b/internal/imager/status.go @@ -18,14 +18,14 @@ type status struct { func (i Imager) loadStatuses(ctx context.Context, tx pgx.Tx) error { file, err := os.OpenFile("data/status.csv", os.O_RDONLY, os.ModePerm) if err != nil { - return fmt.Errorf("Error opening status CSV file: %w", err) + return fmt.Errorf("error opening status CSV file: %w", err) } defer file.Close() var statuses []*status if err = gocsv.UnmarshalFile(file, &statuses); err != nil { - return fmt.Errorf("Error marshaling status CSV file: %w", err) + return fmt.Errorf("error marshaling status CSV file: %w", err) } records := []database.SaveStatusesParams{} @@ -39,7 +39,7 @@ func (i Imager) loadStatuses(ctx context.Context, tx pgx.Tx) error { _, err = i.db.WithTx(tx).SaveStatuses(ctx, records) if err != nil { - return fmt.Errorf("Error saving statuses: %w", err) + return fmt.Errorf("error saving statuses: %w", err) } fmt.Println("[Statuses] seeding complete") diff --git a/sql/schema.sql b/sql/schema.sql deleted file mode 100644 index 5f649cf..0000000 --- a/sql/schema.sql +++ /dev/null @@ -1,163 +0,0 @@ --- We need this for sqlc to reference --- TODO: figure out a better way to do this - -CREATE TABLE circuits ( - id integer NOT NULL, - ref character varying(255) DEFAULT ''::character varying NOT NULL, - name character varying(255) DEFAULT ''::character varying NOT NULL, - location character varying(255), - country character varying(255), - lat double precision, - lng double precision, - alt integer, - url character varying(255) DEFAULT ''::character varying NOT NULL -); - -CREATE TABLE constructor_results ( - id integer NOT NULL, - race_id integer DEFAULT 0 NOT NULL, - constructor_id integer DEFAULT 0 NOT NULL, - points double precision, - status character varying(255) -); -CREATE TABLE constructor_standings ( - id integer NOT NULL, - race_id integer DEFAULT 0 NOT NULL, - constructor_id integer DEFAULT 0 NOT NULL, - points double precision DEFAULT '0'::double precision NOT NULL, - position integer, - position_text character varying(255), - wins integer DEFAULT 0 NOT NULL -); - -CREATE TABLE constructors ( - id integer NOT NULL, - ref character varying(255) DEFAULT ''::character varying NOT NULL, - name character varying(255) DEFAULT ''::character varying NOT NULL, - nationality character varying(255), - url character varying(255) DEFAULT ''::character varying NOT NULL -); - -CREATE TABLE driver_standings ( - id integer NOT NULL, - race_id integer DEFAULT 0 NOT NULL, - driver_id integer DEFAULT 0 NOT NULL, - points double precision DEFAULT '0'::double precision NOT NULL, - position integer, - position_text character varying(255), - wins integer DEFAULT 0 NOT NULL -); - -CREATE TABLE drivers ( - id integer NOT NULL, - ref character varying(255) DEFAULT ''::character varying NOT NULL, - number integer, - code character varying(3), - first_name character varying(255) DEFAULT ''::character varying NOT NULL, - last_name character varying(255) DEFAULT ''::character varying NOT NULL, - date_of_birth date, - nationality character varying(255), - url character varying(255) DEFAULT ''::character varying NOT NULL -); - -CREATE TABLE lap_times ( - race_id integer NOT NULL, - driver_id integer NOT NULL, - lap integer NOT NULL, - position integer, - time character varying(255), - milliseconds integer -); - -CREATE TABLE pit_stops ( - race_id integer NOT NULL, - driver_id integer NOT NULL, - stop integer NOT NULL, - lap integer NOT NULL, - time time without time zone NOT NULL, - duration character varying(255), - milliseconds integer -); - -CREATE TABLE qualifying ( - id integer NOT NULL, - race_id integer DEFAULT 0 NOT NULL, - driver_id integer DEFAULT 0 NOT NULL, - constructor_id integer DEFAULT 0 NOT NULL, - number integer DEFAULT 0 NOT NULL, - position integer, - q1 character varying(255), - q2 character varying(255), - q3 character varying(255) -); - -CREATE TABLE races ( - id integer NOT NULL, - year integer DEFAULT 0 NOT NULL, - round integer DEFAULT 0 NOT NULL, - circuit_id integer DEFAULT 0 NOT NULL, - name character varying(255) DEFAULT ''::character varying NOT NULL, - date date NOT NULL, - time time without time zone, - url character varying(255), - fp1_date date, - fp1_time time without time zone, - fp2_date date, - fp2_time time without time zone, - fp3_date date, - fp3_time time without time zone, - quali_date date, - quali_time time without time zone, - sprint_date date, - sprint_time time without time zone -); - -CREATE TABLE results ( - id integer NOT NULL, - race_id integer DEFAULT 0 NOT NULL, - driver_id integer DEFAULT 0 NOT NULL, - constructor_id integer DEFAULT 0 NOT NULL, - number integer, - grid integer DEFAULT 0 NOT NULL, - position integer, - position_text character varying(255) DEFAULT ''::character varying NOT NULL, - position_order integer DEFAULT 0 NOT NULL, - points double precision DEFAULT '0'::double precision NOT NULL, - laps integer DEFAULT 0 NOT NULL, - time character varying(255), - milliseconds integer, - fastest_lap integer, - rank integer DEFAULT 0, - fastest_lap_time character varying(255), - fastest_lap_speed character varying(255), - status_id integer DEFAULT 0 NOT NULL -); - -CREATE TABLE seasons ( - year integer DEFAULT 0 NOT NULL, - url character varying(255) DEFAULT ''::character varying NOT NULL -); - -CREATE TABLE sprint_results ( - id integer NOT NULL, - race_id integer DEFAULT 0 NOT NULL, - driver_id integer DEFAULT 0 NOT NULL, - constructor_id integer DEFAULT 0 NOT NULL, - number integer DEFAULT 0 NOT NULL, - grid integer DEFAULT 0 NOT NULL, - position integer, - position_text character varying(255) DEFAULT ''::character varying NOT NULL, - position_order integer DEFAULT 0 NOT NULL, - points double precision DEFAULT '0'::double precision NOT NULL, - laps integer DEFAULT 0 NOT NULL, - time character varying(255), - milliseconds integer, - fastest_lap integer, - fastest_lap_time character varying(255), - status_id integer DEFAULT 0 NOT NULL -); - -CREATE TABLE status ( - id integer NOT NULL, - status character varying(255) DEFAULT ''::character varying NOT NULL -);