update to env and gitignore
This commit is contained in:
parent
1c5b853205
commit
f9ceebcd36
@ -5,5 +5,9 @@
|
||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
||||
|
||||
# DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
|
||||
DATABASE_URL="mysql://root:%21Plop2099341723@192.168.50.190:3306/db"
|
||||
MAPS_API_KEY="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJQ-7Uc0BitocRQZASTWUyN04&key=AIzaSyBS4qOnpT4llaFa_UKMpeWike3lzDvFZ1U"
|
||||
# DATABASE_URL="mysql://root:%21Plop2099341723@192.168.50.190:3306/db"
|
||||
MAPS_API_KEY="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJQ-7Uc0BitocRQZASTWUyN04&key=AIzaSyBS4qOnpT4llaFa_UKMpeWike3lzDvFZ1U"
|
||||
|
||||
DATABASE_HOST="aws.connect.psdb.cloud"
|
||||
DATABASE_USERNAME="11lq0wcjbxyku4zmubji"
|
||||
DATABASE_PASSWORD="pscale_pw_AyxGMWCMpaZOsaeeXXem8mrxXPRNJEG0uPUrW2zo1f8"
|
||||
2
Websites/jefes-nextjs/.gitignore
vendored
2
Websites/jefes-nextjs/.gitignore
vendored
@ -19,6 +19,7 @@
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
@ -26,6 +27,7 @@ yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
.env
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
13
Websites/jefes-nextjs/db/db.ts
Normal file
13
Websites/jefes-nextjs/db/db.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { drizzle } from 'drizzle-orm/mysql2';
|
||||
import mysql from 'mysql2/promise';
|
||||
import * as schema from './schema';
|
||||
|
||||
export const connection = mysql.createConnection({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
multipleStatements: true,
|
||||
});
|
||||
|
||||
export const db = drizzle(connection, { schema });
|
||||
12
Websites/jefes-nextjs/db/index.ts
Normal file
12
Websites/jefes-nextjs/db/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// db/index.ts
|
||||
import { drizzle } from "drizzle-orm/planetscale-serverless";
|
||||
import { connect } from "@planetscale/database";
|
||||
|
||||
// create the connection
|
||||
const connection = connect({
|
||||
host: process.env["DATABASE_HOST"],
|
||||
username: process.env["DATABASE_USERNAME"],
|
||||
password: process.env["DATABASE_PASSWORD"],
|
||||
});
|
||||
|
||||
const db = drizzle(connection);
|
||||
9
Websites/jefes-nextjs/db/migrate.ts
Normal file
9
Websites/jefes-nextjs/db/migrate.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import "dotenv/config";
|
||||
import { migrate } from "drizzle-orm/mysql2/migrator";
|
||||
import { db, connection } from "./db";
|
||||
|
||||
// This will run migrations on the database, skipping the ones already applied
|
||||
await migrate(db, { migrationsFolder: "./drizzle" });
|
||||
|
||||
// Don't forget to close the connection, otherwise the script will hang
|
||||
await connection.end();
|
||||
26
Websites/jefes-nextjs/db/schema.ts
Normal file
26
Websites/jefes-nextjs/db/schema.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// db/schema.ts
|
||||
|
||||
import {
|
||||
index,
|
||||
int,
|
||||
mysqlTable,
|
||||
bigint,
|
||||
varchar,
|
||||
} from "drizzle-orm/mysql-core";
|
||||
|
||||
export const users = mysqlTable(
|
||||
"users",
|
||||
{
|
||||
id: bigint("id", { mode: "number" }).primaryKey().autoincrement(),
|
||||
fullName: varchar("full_name", { length: 256 }),
|
||||
},
|
||||
(users) => ({
|
||||
nameIdx: index("name_idx").on(users.fullName),
|
||||
})
|
||||
);
|
||||
|
||||
export const emails = mysqlTable("email", {
|
||||
id: bigint("id", { mode: "number" }).primaryKey().autoincrement(),
|
||||
phone: varchar("phone", { length: 256 }),
|
||||
userId: int("user_id").references(() => users.id),
|
||||
});
|
||||
16
Websites/jefes-nextjs/drizzle.config.ts
Normal file
16
Websites/jefes-nextjs/drizzle.config.ts
Normal file
@ -0,0 +1,16 @@
|
||||
// drizzle.config.ts
|
||||
|
||||
import "dotenv/config";
|
||||
import type { Config } from "drizzle-kit";
|
||||
|
||||
export default {
|
||||
schema: "./db/schema.ts",
|
||||
out: "./drizzle/migrations",
|
||||
driver: "mysql2", // 'pg' | 'mysql2' | 'better-sqlite' | 'libsql' | 'turso'
|
||||
dbCredentials: {
|
||||
host: process.env.DB_HOST!,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME!,
|
||||
},
|
||||
} satisfies Config;
|
||||
@ -0,0 +1,27 @@
|
||||
CREATE TABLE `email`
|
||||
(
|
||||
`id` bigint AUTO_INCREMENT NOT NULL,
|
||||
`phone` varchar
|
||||
(256),
|
||||
`user_id` int,
|
||||
CONSTRAINT `email_id` PRIMARY KEY
|
||||
(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `users`
|
||||
(
|
||||
`id` bigint AUTO_INCREMENT NOT NULL,
|
||||
`full_name` varchar
|
||||
(256),
|
||||
CONSTRAINT `users_id` PRIMARY KEY
|
||||
(`id`)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `name_idx` ON `users`
|
||||
(`full_name`);--> statement-breakpoint
|
||||
ALTER TABLE `email`
|
||||
ADD CONSTRAINT `email_user_id_users_id_fk` FOREIGN KEY
|
||||
(`user_id`) REFERENCES `users`
|
||||
(`id`) ON
|
||||
DELETE no action ON
|
||||
UPDATE no action;
|
||||
103
Websites/jefes-nextjs/drizzle/migrations/meta/0000_snapshot.json
Normal file
103
Websites/jefes-nextjs/drizzle/migrations/meta/0000_snapshot.json
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"version": "5",
|
||||
"dialect": "mysql",
|
||||
"id": "9edb1131-47b9-43e7-9252-e68e1e3dc66f",
|
||||
"prevId": "00000000-0000-0000-0000-000000000000",
|
||||
"tables": {
|
||||
"email": {
|
||||
"name": "email",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"phone": {
|
||||
"name": "phone",
|
||||
"type": "varchar(256)",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "int",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"email_user_id_users_id_fk": {
|
||||
"name": "email_user_id_users_id_fk",
|
||||
"tableFrom": "email",
|
||||
"tableTo": "users",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {
|
||||
"email_id": {
|
||||
"name": "email_id",
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"users": {
|
||||
"name": "users",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"full_name": {
|
||||
"name": "full_name",
|
||||
"type": "varchar(256)",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"name_idx": {
|
||||
"name": "name_idx",
|
||||
"columns": [
|
||||
"full_name"
|
||||
],
|
||||
"isUnique": false
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {
|
||||
"users_id": {
|
||||
"name": "users_id",
|
||||
"columns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {}
|
||||
}
|
||||
},
|
||||
"schemas": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
}
|
||||
}
|
||||
13
Websites/jefes-nextjs/drizzle/migrations/meta/_journal.json
Normal file
13
Websites/jefes-nextjs/drizzle/migrations/meta/_journal.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "5",
|
||||
"dialect": "mysql",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "5",
|
||||
"when": 1701338981518,
|
||||
"tag": "0000_charming_blindfold",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
2465
Websites/jefes-nextjs/package-lock.json
generated
2465
Websites/jefes-nextjs/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,12 +9,15 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@planetscale/database": "^1.11.0",
|
||||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"@react-google-maps/api": "^2.19.2",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"classnames": "^2.3.2",
|
||||
"clsx": "^2.0.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"drizzle-orm": "^0.29.1",
|
||||
"easymde": "^2.18.0",
|
||||
"embla-carousel-auto-height": "^8.0.0-rc14",
|
||||
"embla-carousel-autoplay": "^8.0.0-rc14",
|
||||
@ -39,6 +42,7 @@
|
||||
"@types/react-dom": "^18",
|
||||
"autoprefixer": "^10",
|
||||
"daisyui": "^3.9.3",
|
||||
"drizzle-kit": "^0.20.6",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.0.3",
|
||||
"postcss": "^8",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"target": "es2022",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user