Build and Deploy a GraphQL API to the Edge with MySQL and PlanetScale — Part 2
Set up MySQL Database with PlanetScale
PlanetScale is the best place to serve and scale your MySQL Database. You'll need to create an account, create a database, add a products table, and obtain the connection details to continue.
Sign up for a PlanetScale account
Create a new database
Create a new branch and open the web console to execute the following SQL statement:
CREATE TABLE `products` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`slug` VARCHAR(255) NOT NULL UNIQUE,
`price` INT NOT NULL DEFAULT 0,
`onSale` BOOLEAN DEFAULT FALSE,
PRIMARY KEY (`id`),
INDEX slug_index (`slug`),
);
Enable safe migrations for the main branch
Open a deploy request and merge the changes into
main
.
That's it! You now have a database we can use to store product data.