Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gary A. Stafford
committed
Aug 10, 2019
0 parents
commit 8aa97e9
Showing
17 changed files
with
48,839 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Gary A. Stafford | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
Pagila | ||
====== | ||
|
||
Pagila is a port of the Sakila example database available for MySQL, which was | ||
originally developed by Mike Hillyer of the MySQL AB documentation team. It | ||
is intended to provide a standard schema that can be used for examples in | ||
books, tutorials, articles, samples, etc. | ||
|
||
All the tables, data, views, and functions have been ported; some of the | ||
changes made were: | ||
|
||
* Changed char(1) true/false fields to true boolean fields | ||
* The last_update columns were set with triggers to update them | ||
* Added foreign keys | ||
* Removed 'DEFAULT 0' on foreign keys since it's pointless with real FK's | ||
* Used PostgreSQL built-in fulltext searching for fulltext index. | ||
Removed the need for the film_text table. | ||
* The rewards_report function was ported to a simple SRF | ||
|
||
The schema and data for the Sakila database were made available under the BSD | ||
license which can be found at http://www.opensource.org/licenses/bsd-license.php. | ||
The pagila database is made available under this license as well. | ||
|
||
|
||
FULLTEXT SEARCH | ||
--------------- | ||
|
||
Fulltext functionality is built in PostgreSQL, so parts of the schema exist | ||
in the main schema file. | ||
|
||
Example usage: | ||
|
||
SELECT * FROM film WHERE fulltext @@ to_tsquery('fate&india'); | ||
|
||
|
||
PARTITIONED TABLES | ||
------------------ | ||
|
||
The payment table is designed as a partitioned table with a 6 month timespan | ||
for the date ranges. | ||
If you want to take full advantage of table partitioning, you need to make | ||
sure constraint_exclusion is turned on in your database. You can do this by | ||
setting "constraint_exclusion = on" in your postgresql.conf, or by issuing the | ||
command "ALTER DATABASE pagila SET constraint_exclusion = on" (substitute | ||
pagila for your database name if installing into a database with a different | ||
name) | ||
|
||
|
||
INSTALL NOTE | ||
------------ | ||
|
||
The pagila-data.sql file and the pagila-insert-data.sql both contain the same | ||
data, the former using COPY commands, the latter using INSERT commands, so you | ||
only need to install one of them. Both formats are provided for those who have | ||
trouble using one version or another. | ||
|
||
VERSION HISTORY | ||
--------------- | ||
|
||
Version 2.0 | ||
* Update schema for newer PostgreSQL versions | ||
* Remove RULE for partitioning, add trigger support. | ||
* Update years in sample data. | ||
* Remove ARTICLES section from README, all links are dead. | ||
|
||
Version 0.10.1 | ||
* Add pagila-data-insert.sql file, added articles section | ||
|
||
Version 0.10 | ||
* Support for built-in fulltext. Add enum example | ||
|
||
Version 0.9 | ||
* Add table partitioning example | ||
|
||
Version 0.8 | ||
* First release of pagila |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Getting Started with PostgreSQL using Amazon RDS, CloudFormation, pgAdmin, and Python | ||
Source code for post, (Getting Started with PostgreSQL using Amazon RDS, CloudFormation, pgAdmin, and Python)[]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
Description: "RDS EventSubscription/SNS/SMS Alerts" | ||
Parameters: | ||
DBAlertPhoneNumber: | ||
Type: String | ||
Default: "{{resolve:ssm:/rds_demo/alert_phone:1}}" | ||
Resources: | ||
MyDBSNSTopic: | ||
Type: AWS::SNS::Topic | ||
Properties: | ||
Subscription: | ||
- Endpoint: | ||
Ref: DBAlertPhoneNumber | ||
Protocol: sms | ||
TopicName: "RDSAlertTopic" | ||
MyEventSubscription: | ||
Properties: | ||
Enabled: true | ||
EventCategories: | ||
- availability | ||
- configuration change | ||
- creation | ||
- deletion | ||
- failover | ||
- failure | ||
- recovery | ||
SnsTopicArn: | ||
Ref: MyDBSNSTopic | ||
# SourceIds: | ||
# - Ref: MyDB | ||
# - Ref: MyReadReplica | ||
SourceType: db-instance | ||
Type: AWS::RDS::EventSubscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
Description: | ||
This template deploys a VPC with a pair of subnets spread | ||
across two Availability Zones. It deploys an Internet Gateway, | ||
with a default route on the public subnets. It deploys an RDS | ||
PostgreSQL master and single read replica databaes. | ||
Parameters: | ||
VpcCIDR: | ||
Description: IP range (CIDR notation) for this VPC | ||
Type: String | ||
Default: "10.0.0.0/24" | ||
AllowedPattern: "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}" | ||
SubnetMasterCIDR: | ||
Description: IP range (CIDR notation) for the subnet in the RDS Master Availability Zone | ||
Type: String | ||
Default: "10.0.0.0/28" | ||
AllowedPattern: "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}" | ||
SubnetReplicaCIDR: | ||
Description: IP range (CIDR notation) for the subnet in the RDS Read Replica Availability Zone | ||
Type: String | ||
Default: "10.0.0.16/28" | ||
AllowedPattern: "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}" | ||
DBInstanceIdentifier: | ||
Type: String | ||
Default: "demo-instance" | ||
ReplicaInstanceIdentifier: | ||
Type: String | ||
Default: "demo-replica" | ||
DBEngine: | ||
Type: String | ||
Default: "postgres" | ||
DBEngineVersion: | ||
Type: String | ||
Default: "11.4" | ||
DBSourceRegion: | ||
Type: String | ||
Default: "us-east-1" | ||
DBInstanceClass: | ||
Type: String | ||
Default: "db.t3.small" | ||
DBStorageType: | ||
Type: String | ||
Default: "gp2" | ||
DBAllocatedStorage: | ||
Type: Number | ||
Default: 10 | ||
DBName: | ||
Type: String | ||
Default: "{{resolve:ssm:/rds_demo/db_name:1}}" | ||
DBUser: | ||
Type: String | ||
Default: "{{resolve:ssm:/rds_demo/master_username:1}}" | ||
DBPassword: | ||
Type: String | ||
Default: "{{resolve:ssm-secure:/rds_demo/master_password:1}}" | ||
NoEcho: True | ||
Resources: | ||
VPC: | ||
Type: AWS::EC2::VPC | ||
Properties: | ||
CidrBlock: !Ref VpcCIDR | ||
EnableDnsSupport: true | ||
EnableDnsHostnames: true | ||
Tags: | ||
- Key: Name | ||
Value: Demo VPC | ||
InternetGateway: | ||
Type: AWS::EC2::InternetGateway | ||
Properties: | ||
Tags: | ||
- Key: Name | ||
Value: Internet Gateway | ||
InternetGatewayAttachment: | ||
Type: AWS::EC2::VPCGatewayAttachment | ||
Properties: | ||
InternetGatewayId: !Ref InternetGateway | ||
VpcId: !Ref VPC | ||
SubnetMasterDB: | ||
Type: AWS::EC2::Subnet | ||
Properties: | ||
VpcId: !Ref VPC | ||
AvailabilityZone: !Select [ 0, !GetAZs '' ] | ||
CidrBlock: !Ref SubnetMasterCIDR | ||
MapPublicIpOnLaunch: true | ||
Tags: | ||
- Key: Name | ||
Value: Master Subnet (AZ1) | ||
SubnetReplicaDB: | ||
Type: AWS::EC2::Subnet | ||
Properties: | ||
VpcId: !Ref VPC | ||
AvailabilityZone: !Select [ 1, !GetAZs '' ] | ||
CidrBlock: !Ref SubnetReplicaCIDR | ||
MapPublicIpOnLaunch: true | ||
Tags: | ||
- Key: Name | ||
Value: Replica Subnet (AZ2) | ||
PublicRouteTable: | ||
Type: AWS::EC2::RouteTable | ||
Properties: | ||
VpcId: !Ref VPC | ||
Tags: | ||
- Key: Name | ||
Value: Public Route Table | ||
DefaultPublicRoute: | ||
Type: AWS::EC2::Route | ||
DependsOn: InternetGatewayAttachment | ||
Properties: | ||
RouteTableId: !Ref PublicRouteTable | ||
DestinationCidrBlock: 0.0.0.0/0 | ||
GatewayId: !Ref InternetGateway | ||
SubnetMasterRouteTableAssoc: | ||
Type: AWS::EC2::SubnetRouteTableAssociation | ||
Properties: | ||
RouteTableId: !Ref PublicRouteTable | ||
SubnetId: !Ref SubnetMasterDB | ||
SubnetReplicaRouteTableAssoc: | ||
Type: AWS::EC2::SubnetRouteTableAssociation | ||
Properties: | ||
RouteTableId: !Ref PublicRouteTable | ||
SubnetId: !Ref SubnetReplicaDB | ||
DBSubnetGroup: | ||
Properties: | ||
DBSubnetGroupDescription: DBSubnetGroup for RDS instances | ||
SubnetIds: | ||
- Ref: SubnetMasterDB | ||
- Ref: SubnetReplicaDB | ||
Type: AWS::RDS::DBSubnetGroup | ||
VpcDefaultSecurityGroupIngress: | ||
Type: AWS::EC2::SecurityGroupIngress | ||
Properties: | ||
GroupId: !GetAtt VPC.DefaultSecurityGroup | ||
CidrIp: 0.0.0.0/0 | ||
IpProtocol: tcp | ||
FromPort: 5432 | ||
ToPort: 5432 | ||
DemoMasterInstance: | ||
Properties: | ||
DBInstanceIdentifier: | ||
Ref: DBInstanceIdentifier | ||
DBName: | ||
Ref: DBName | ||
AllocatedStorage: | ||
Ref: DBAllocatedStorage | ||
DBInstanceClass: | ||
Ref: DBInstanceClass | ||
StorageType: | ||
Ref: DBStorageType | ||
Engine: | ||
Ref: DBEngine | ||
EngineVersion: | ||
Ref: DBEngineVersion | ||
MasterUsername: | ||
Ref: DBUser | ||
MasterUserPassword: | ||
Ref: DBPassword | ||
PubliclyAccessible: True | ||
Tags: | ||
- Key: Name | ||
Value: "Demo RDS PostgreSQL Master" | ||
VPCSecurityGroups: | ||
- !GetAtt VPC.DefaultSecurityGroup | ||
DBSubnetGroupName: | ||
Ref: DBSubnetGroup | ||
Type: AWS::RDS::DBInstance | ||
DemoReadReplica: | ||
Properties: | ||
DBInstanceIdentifier: | ||
Ref: ReplicaInstanceIdentifier | ||
AllocatedStorage: | ||
Ref: DBAllocatedStorage | ||
DBInstanceClass: | ||
Ref: DBInstanceClass | ||
SourceDBInstanceIdentifier: | ||
Ref: DemoMasterInstance | ||
SourceRegion: | ||
Ref: DBSourceRegion | ||
Tags: | ||
- Key: Name | ||
Value: "Demo RDS PostgreSQL Read Replica" | ||
Type: AWS::RDS::DBInstance | ||
Outputs: | ||
EndpointMaster: | ||
Description: "Endpoint of the newly created RDS master" | ||
Value: DemoMasterInstance | ||
EndpointReplica: | ||
Description: "Endpoint of the newly created RDS replica" | ||
Value: DemoReadReplica |
Oops, something went wrong.