what tables...
parent
738992468a
commit
031d5f545d
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
func Config(ctx context.Context) (context.Context, error) {
|
||||
ctx, err := db.Inject(ctx)
|
||||
ctx, err := db.Inject(ctx, "/tmp/f.db")
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,39 @@ package cron
|
|||
import (
|
||||
"context"
|
||||
"io"
|
||||
"show-rss/src/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Main(ctx context.Context) error {
|
||||
c := time.NewTicker(time.Minute)
|
||||
defer c.Stop()
|
||||
for {
|
||||
if err := one(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-c.C:
|
||||
}
|
||||
}
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func one(ctx context.Context) error {
|
||||
if err := initDB(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return io.EOF
|
||||
}
|
||||
|
||||
func initDB(ctx context.Context) error {
|
||||
return db.Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS feeds (
|
||||
id SERIAL
|
||||
);
|
||||
ALTER TABLE feeds ADD COLUMN IF NOT EXISTS b TEXT;
|
||||
ALTER TABLE feeds ADD COLUMN IF NOT EXISTS b TEXT;
|
||||
`)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue