That was your problem in a nutshell ๐
That was your problem in a nutshell 
id (in line with kv format), but then the example uses database_id. Which one is it?
database_id id SERIAL PRIMARY KEY seems not work, I follow the doc https://developers.cloudflare.com/workers/tutorials/postgres/#5-interact-with-the-products-database, I know the condition is own host PostgreSQL but the D1 should be the same, right?

id int primary key autoincrementPRIMARY KEY need to be the last "field", so after createdAtD1_ERROR: Error: ERROR 9007: SQL execute error: UNIQUE constraint failed: User.emailD1_ERROR: Error so that I can't detect existed email ERROR 9015: SQL engine error: query error: Error code 2067: A UNIQUE constraint failed (UNIQUE constraint failed: User.email)error.cause?.message
let me PR that 

wrangler d1 execute?
)
env but instead context.env per the linked docsdatabase_iddatabase_id id SERIAL PRIMARY KEYid int primary key autoincrementERROR 9009: SQL prepare error: near "createdAt": syntax error in CREATE TABLE Love( uid integer NOT NULL, ideaId integer NOT NULL, PRIMARY KEY (uid, ideaId), createdAt datetime DEFAULT CURRENT_TIMESTAMP ); at offset 109PRIMARY KEYD1_ERROR: Error: ERROR 9007: SQL execute error: UNIQUE constraint failed: User.emailD1_ERROR: ErrorERROR 9015: SQL engine error: query error: Error code 2067: A UNIQUE constraint failed (UNIQUE constraint failed: User.email)error.cause?.messagewrangler d1 executecontext.envinterface Env {
YOUR_DB: D1Database;
}
export const onRequest: PagesFunction<Env> = async (context) => {
// Create a prepared statement with our query
const ps = context.env.YOUR_DB.prepare('SELECT * from users');
const data = await ps.first();
return Response.json(data);
}CREATE TABLE Love(
uid integer NOT NULL,
ideaId integer NOT NULL,
PRIMARY KEY (uid, ideaId),
createdAt datetime DEFAULT CURRENT_TIMESTAMP
);console.log(query);
result = context.env.db.prepare(query).bind(value);
const res = await result.raw();
console.log("RESULT: "+res);